可能重复:
如何访问此变量?
可以说我有代码:
class Player
def getsaves
print "Saves: "
saves = gets
end
def initialize(saves, era, holds, strikeouts, whip)
end
end
我希望能够在初始化方法中访问getsaves中的saves变量说:
j = Player.new(getsaves_saves_variable, 30, 30, 30, 30)