我想知道在 Ruby 中是否有更优雅的方式来表达这一点:
FREE_PLAN_MAXIMUM = 1
BASIC_PLAN_MAXIMUM = 10
PREMIUM_PLAN_MAXIMUM = 100
def maximum_entries_per_month
case plan
when "premium"
PREMIUM_PLAN_MAXIMUM
when "basic"
BASIC_PLAN_MAXIMUM
else
FREE_PLAN_MAXIMUM
end
end
我不喜欢函数内部的premium
重复。basic
什么可能是替代方案?