I am trying to translate the below Python code to Ruby. I would like to access "a" and change it in the future.
class c:
def __init__(self, a):
self.a = a
o = new c(2)
print(o.a)
I read about instance variables of Ruby, but the tutorials are very long and confusing. I have tried:
class C
def initialize(a)
@a = a
end
end
o = C.new(2)
puts o.a
but it just doesn't work. I end up with this:
class C
def initialize(a)
@a = a
def a
@a
end
end
end
but this one is just too stupid.
Can someone please just translate above Python code correctly to Ruby? Thank you!