Logo

Programming-Idioms

History of Idiom 137 > diff from v26 to v27

Edit summary for version 27 by aperc:
New Scala implementation by user [aperc]

Version 26

2019-09-26, 13:42:29

Version 27

2019-09-26, 13:50:27

Idiom #137 Check if string contains only digits

Set boolean b to true if string s contains only characters in range '0'..'9', false otherwise.

Idiom #137 Check if string contains only digits

Set boolean b to true if string s contains only characters in range '0'..'9', false otherwise.

Code
def onlyDigits(s: String) = s.forall(_.isDigit)