M
mwmarkland
I have been reading _The Ruby Way_ and am confused by the temperature
conversion sample program on page 14.
The line in question is
abort "#{temp} is not a valid number." if temp !~ /-?\d+/
What I do not understand is that if \d matches "digits", which I
understand to be [0-9], how can this expression match "98.6", which it
seems to do just fine.
Thank you in advance for the clarification.
(I have the 2nd Edition of _The Ruby Way_, First Printing. I have run
the example using ruby 1.8.5 (2007-03-13 patchlevel 35) [i386-linux]).
Matt
conversion sample program on page 14.
The line in question is
abort "#{temp} is not a valid number." if temp !~ /-?\d+/
What I do not understand is that if \d matches "digits", which I
understand to be [0-9], how can this expression match "98.6", which it
seems to do just fine.
Thank you in advance for the clarification.
(I have the 2nd Edition of _The Ruby Way_, First Printing. I have run
the example using ruby 1.8.5 (2007-03-13 patchlevel 35) [i386-linux]).
Matt