Logo

Programming-Idioms

History of Idiom 137 > diff from v15 to v16

Edit summary for version 16 by programming-idioms.org:
[Ruby] +DemoURL

Version 15

2016-11-06, 21:16:21

Version 16

2016-11-13, 14:31:01

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
b = s.count("^0-9").zero?
Code
b = s.count("^0-9").zero?
Demo URL
https://repl.it/EWc5/1