Hash assignment (what's happening?)

H

Hector Quiroz

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.
 
H

Hector Quiroz

Hector said:
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
 
D

dima

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.

I think this could help :)
http://blog.wordaligned.org/articles/2006/08/12/octal-literals
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top