我在这里做错了什么?我试图获得销售税,并最终将其用于数学计算?Ruby类获得销售税
class Item
def initialize(type)
@type = type
def tax_calc(type)
if type.include?("book")
sales_tax = 0
else
sales_tax = 2
end
end
end
puts "what is type"
type2 = gets
Item.new(type2)
puts sales_tax
你为什么不告诉我们它对你的行为如何,以及与你想要做什么相比这是怎么回事? –