Seeing numbers in Ruby with r attached to the number -
when come across numbers in ruby code, mean?
1r
or
1.0r
tested in ruby 1.8.6 2.0.0 , fails. this:
>> 1r syntaxerror: unexpected tidentifier, expecting end-of-input
and
>> 1.0r syntaxerror: unexpected tidentifier, expecting end-of-input
probably downvoted not searching, or something, or not enough examples. clarifies. ruby code, doesn't have anywhere, has there.
that new feature decimal/rational literals in ruby 2.1. see here: http://rkh.im/ruby-2.1 (search "decimal literals")
0.1r #=> (1/10) 0.1r * 3 #=> (3/10)
Comments
Post a Comment