I have this sample class below.
class MyClass
def initialize(options = {})
@input = options[:input]
end
def trigger
# I want to remember previous input value if this method called.
input
end
end
How can I store or remember the previous value that was previously input? For example.
my_class = MyClass.new(input: "first")
my_class.trigger
=> first
If I call:
my_class.input = "second"
I want to remember the previous value input which is "fisrt"
. How can I achieve this?
Aucun commentaire:
Enregistrer un commentaire