I am trying to figure out if it is possible to pass a value between methods in a Ruby class.
I haven't found much on my own and figured I would ask the experts. Could it be done passed as a arg/parameter to another method as well?
class PassingValues
def initialize
@foo = 1
end
def one
@foo += 1
end
def two
@foo += 1
end
def three
p @foo
end
end
bar = PassingValues.new
If I wanted this to print out foo value of 3:
bar.three