【发布时间】:2012-01-28 16:37:06
【问题描述】:
feelings = Set["happy", "sad", "angry", "high", "low"]
euphoria = Set["happy", "high"]
dysphoria = Set["sad", "low"]
miserable = Set["sad", "angry"]
puts "How do you feel?"
str = gets.chomp
p terms = str.split(',')
if euphoria.proper_subset? feelings
puts "You experiencing a state of euphoria."
else
puts "Your experience is undocumented."
end
gets
我如何将 euphoria 设为变量,这样如果对应的 miserable 或 dysphoria 字符串匹配并显示集合名称。喜欢#{Set}
【问题讨论】: