我试着写一个应用程序,从单词列表中移除的话:检查数组包含字符串,不区分大小写
puts "Words:"
text = gets.chomp
puts "Words to remove:"
remove = gets.chomp
words = text.split(" ")
removes = remove.split(" ")
words.each do |x|
if removes.include.upcase? x.upcase
print "REMOVED "
else
print x, " "
end
end
我怎么会做出这种区分大小写? 我试过把.upcase
放在那里,但没有运气。
在哪里?目前尚不清楚你尝试过什么。 if语句中的 – 2013-02-09 22:48:46
。 编辑OP – krtek 2013-02-09 22:51:40
你不需要每个元素的情况? – 2013-02-09 22:54:06