是否可以在gets.chomp
,if
的{{1}}列表中找到字符串?
elsif
答案 0 :(得分:0)
要查找数组中是否存在元素,可以使用include?。这里:
if mult_of_three.include?(number)
示例:
number = gets.chomp
36
# => "36"
mult_of_three.include?(number)
# => true
number = gets.chomp
98
# => "98"
mult_of_three.include?(number)
# => false