VIRTUAL COMPUTER - 1. What You'll Be Building, eric => 668


#1

Probably not going to copy the entire line of code but… (here)
In the default provided code, line 22 and 23.

22| my_machine = Machine.new("eric", 01234)
23| your_machine = Machine.new("you", 56789)
28| puts "Users: #{Machine.get_users}"

Output:

Users: {"eric"=> 668, "you"=>56789}

if I changed it to

22| my_machine = Machine.new("eric", 11234) #Changed to 11234

Output:

Users: {"eric"=>11234, "you"=>56789}

Could someone explain to me why Users Eric != 01234 but 668?

EDIT:
OK, I found out that although 01234 is a fixnum, 01234 base8 == 668 base10

Why is it that 668 is then taken and interpreted as an int rather than as 01234?
and
Are there any other data conversion of ruby that isn’t (or I missed it) explained? Like 0x1234 (base16) == 4660 (base10)


#3

You can’t start integers with a zero.
It’s common to most languages