In Ruby, is there a difference between `self.i` and `@i`?
There is, of course, a difference betwenn
@iwill return the value assigned to the variable
self.iwill return the value which was returned by a method named
Animal class has no
i method defined, therefore the error message is correct.
When you want
self.i to return the value of the
@i variable then you need to create a
i method like this
def i @i end
or simply use the
attr_reader macro like this:
class Animal attr_reader :i #... end