我正在运行Learn Ruby the Hard Way 的练习 14。如果我在 cmd 中运行脚本,它可以正常工作,但我一直在使用 Cygwin,因为它更好。当我使用以下命令在 cygwin 中运行它时:
ruby ex14.rb Devon
我得到以下输出
test
one
two
Hi Devon, I'm the ex14.rb script.
I'd like to ask you a few questions.
Do you like me Devon?
> Where do you live Devon?
> What kind of computer do you have?
> Alright, so you said test about liking me.
You live in one. Not sure where that is.
And you have a two computer. Nice.
也就是说,程序启动并立即运行这三个STDIN.gets.chomp()
命令,一旦通过这些命令,它就会puts
立即执行prints
所有操作。
有没有办法解决这种行为?我显然想让这些行按照它们写的顺序运行。我不确定要为这种类型的错误谷歌什么 - “cygwin”、“ruby”、“延迟输出”和“乱序”的组合没有返回任何相关信息。无论如何,这些搜索词似乎含糊不清。
到底发生了什么,有解决办法吗?