Re: Number underscored gone wrong
Jeremy Bopp <[email protected]> Tue, 17 Sep 2019 10:15:45 -0500
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <CA+=tguxPRco+dpBhxxfVmTJ1iPwT3o3RbjWkDWqSordqjXMGyw@mail.gmail.com> |
Any number with a leading 0 is treated as an octal representation rather than decimal. [1] pry(main)> 0_50 => 40 [2] pry(main)> 050 => 40 [3] pry(main)> 050.to_s(10) => "40" [4] pry(main)> 050.to_s(8) => "50" -Jeremy On Tue, Sep 17, 2019 at 10:13 AM Peter L <[email protected]> wrote: > Dear ruby fans... > > Just a quick question: I always thought underscores in numbers were > ignored, like 100_000, 10_00 or 666_6. > > Buuut: did anyone of you tried to do following? > > > 0_50 > > WTH :) > > Really - try it :) > > Would be great if someone could answer why this is not working as I > imagined? :) > > Have a nice afternoon! > > Unsubscribe: <mailto:[email protected]?subject=unsubscribe> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk> > Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>