cool_words = [] while true cool_words.push gets break if gets.chomp == '' end puts cool_words
它只是推动第一个条目,然后是第三个,然后是第五个.我认为这是我打破循环的break方式,因为没有方法它就不会发生.
break
break当我在空行中按Enter 键时,我需要它离开循环.
提前致谢!
ruby push
push ×1
ruby ×1