[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Hash assignment (what's happening?

Quiroz, Hector

10/5/2007 2:16:00 PM

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

2 Answers

Quiroz, Hector

10/5/2007 2:18:00 PM

0

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

Dejan Dimic

10/5/2007 2:26:00 PM

0

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

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