2016-09-16 80 views
3

我只是写了这个简单的脚本循环不起作用:红宝石:直到预期

#!/bin/env ruby 

begin 
    print "Continue? [Y/n] " 
    key = gets 
end until key == 'n' 

我想到,如果我打的“n”键,循环将结束。但这并没有发生。无论我发送什么密钥,循环始终继续: until loop problem

我在做什么错?

+1

可能的重复[为什么我没有成功从这个Ruby循环中断?](http://stackoverflow.com/questions/20820721/why-am-i-not-successfully-breaking-from-this-ruby-循环) –

回答