モデルまたはコントローラーに 2 つのメソッドがあり、メソッド間で変数を渡したい場合など
def foo
@param = 2
@test = 1
callee
#do something with @test
end
def callee
@test += @param
end
これを行うにはインスタンス変数を使用する方が良いですか、それとも通常の変数を使用する方が良いですか?
def foo
param = 2
test = 1
test = callee(param, test)
#do something with test
end
def callee(param, test)
test += param
test
end
前もって感謝します!