Re: Number underscored gone wrong
Peter L <[email protected]> Tue, 17 Sep 2019 17:17:20 +0200
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <[email protected]> |
Ahhh, I see... Weird though :D Thank you! > Am 17.09.2019 um 17:15 schrieb Jeremy Bopp <[email protected] <mailto:[email protected]>>: > > 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] <mailto:[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] <mailto:[email protected]>?subject=unsubscribe> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>> > > Unsubscribe: <mailto:[email protected]?subject=unsubscribe <mailto:[email protected]?subject=unsubscribe>> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk <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>