I thought, and tried, using @i and self.i interchangeably, but it gives an error:
class Animal
def initialize i
@i = i
end
def get_i
self.i
end
end
a = Animal.new("Sparky")
puts a.get_i()
Outputs:
source_file.rb:8:in `get_i':
undefined method `i' for #<Animal:0x000000010d5330 @i="Sparky">
(NoMethodError)
from source_file.rb:12:in `<main>'
Is there any difference in terms of how the interpreter handles the code?