Hector1
(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.
···
--
Posted via http://www.ruby-forum.com/.
Hector1
(Hector)
2
Hector Quiroz 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
···
--
Posted via http://www.ruby-forum.com/\.
I think this could help 
http://blog.wordaligned.org/articles/2006/08/12/octal-literals
···
On Oct 5, 4:16 pm, Hector Quiroz <hqui...@enh.org> 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.
--
Posted viahttp://www.ruby-forum.com/.
Jason_R
(Jason R.)
4
Prefixing a '0' to a number makes it octal. Either make it a string or don't
add the 0.
Jason
···
On 10/5/07, Hector Quiroz <hquiroz@enh.org> 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.
--
Posted via http://www.ruby-forum.com/\.