Reputation: 21
I am trying to have sushiable?
return an instance variable set in initialise
but I can't seem to get it to work. What am I doing wrong?
attr_accessor :weight, :value, :sushiable?
def initialize (weight,value, sushiable?)
@weight = weight
@value = value
@sushiable = sushiable?
end
# def sushiable?
# false
# end
Upvotes: 0
Views: 54
Reputation: 1082
Using ?
is only valid for methods names, not for variables. So, the correct way would be:
attr_accessor :weight, :value, :sushiable
def initialize (weight, value, sushiable)
@weight = weight
@value = value
@sushiable = sushiable
end
def sushiable?
sushiable
end
Upvotes: 4