hector
1
From within irb, I’m creating a hash and populating it with the
following data.
irb(main):007:0> {:QHector => 1967, :WKelly => 2551, :ECron => 0220,
:VLaura => 4003, :LWalter => 1188}
Why is the value for the ‘:ECron’ coming back as 144 instead of 0220?
=> {:ECron=>144, :VLaura=>4003, :LWalter=>1188, :QHector=>1967,
:WKelly=>2551}
irb(main):008:0>
Thanks for your help in advance.
hector
2
Hector Q. wrote:
From within irb, I’m creating a hash and populating it with the
following data.
irb(main):007:0> {:QHector => 1967, :WKelly => 2551, :ECron => 0220,
:VLaura => 4003, :LWalter => 1188}
Why is the value for the ‘:ECron’ coming back as 144 instead of 0220?
=> {:ECron=>144, :VLaura=>4003, :LWalter=>1188, :QHector=>1967,
:WKelly=>2551}
irb(main):008:0>
Thanks for your help in advance.
Oops, the number is being interpreted by ruby as an Octal! Duh.
hq
hector
3
On Oct 5, 4:16 pm, Hector Q. [email protected] wrote:
irb(main):008:0>
Thanks for your help in advance.
Posted viahttp://www.ruby-forum.com/.
I think this could help 
http://blog.wordaligned.org/articles/2006/08/12/octal-literals
hector
4
Prefixing a ‘0’ to a number makes it octal. Either make it a string or
don’t
add the 0.
Jason