这个问题不太可能帮助任何 future 的访客;它仅与一个小地理区域、一个特定时刻或一个非常狭窄的情况相关,而这些情况通常不适用于互联网的全局受众。如需帮助使这个问题更广泛地适用,visit the help center .
9年前关闭。
运行正确:
C:\>ruby -00 -e 'a= gets; puts a ;puts "here is: #{$/.inspect}"'
Hi #[pressed ENTER]
[pressed ENTER]
Hi # <~~ here Hi came as the output, as expected.
here is: "\n\n" #<~~ here Hi came as the output, as expected.
C:\>
但是当我的 Ubuntu 机器上发生这种情况时,我感到很惊讶:
@ubuntu:~$ ruby -00 -e 'a= gets; puts a ;puts "here is: #{$/.inspect}"'
> hi # [pressed ENTER]
> [pressed ENTER]
> hi #[pressed ENTER]
> ^C
@ubuntu:~$
有什么建议可以让它在 Ubuntu 中运行吗?
最佳答案
在 Ubuntu 中对我来说非常好用:
% ruby -00 -e 'a = gets; puts a; puts "here is #{$/.inspect}"'
hi
hi
here is "\n\n"
看起来您只是缺少命令中的最后一个单引号。
关于Ubuntu 中的 Ruby 解释器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14881469/