Working through an intro Ruby exercise with this code:
num = 8
7.times do
print num.type, " ", num, "\n"
num *= num
end
I keep getting:
NoMethodError: undefined method `type' for 8:Fixnum
Do i have to define type? I thought this was a method that ruby recognized
The type
method used to return an object's class but was deprecated a long time ago (back in the 1.8 days) and subsequently removed.
You can use the class
method instead, however if you are following a tutorial or something similar this is a sign that it is very old - possibly 10 years old!