From: Paul Lutus Date: 2006-11-18T02:45:05+09:00 Subject: Re: ruby equivalent PHP function is_numeric? Rimantas Liubertas wrote: >> > After reading completely my Ruby book, I cannot find a function >> > equivalent to the PHP is_numeric? to test a String >> > >> > myString.is_numeric? (check only digits and dot character) => >> > return true or false > <...> > >> def is_numeric?(s) >> return (s.to_s =~ /^\d+(\.\d+|\d*)$/)?true:false >> end > <...> > >>> is_numeric?("1000_000") > => false > > In ruby it is not only about dot and digits, but also underscores. What purpose does the underscore play? I see that it is accepted, I just can't figure out why. I have never seen it as part of proper numeric syntax, anywhere, in three decades in this business. a = 1_2_3_4_5_6_7 # => 1234567 What's the point? -- Paul Lutus http://www.arachnoid.com