为什么我输错字符串后 IRB 无法工作?
我开始使用IRB学习Ruby,并在下面写了错误的代码:
irb(main):001:0>"amefurashi".delete(aiueo")
我注意到它缺少双引号,提示符变为:
irb(main):002:1"
我写了正确的代码:
irb(main):001:1"amefurashi".delete("aiueo")
但为什么它不起作用?
I started to learn Ruby using IRB and wrote the wrong code below:
irb(main):001:0>"amefurashi".delete(aiueo")
I noticed it was missing a double-quote mark, and the prompt changed to:
irb(main):002:1"
I wrote the correct code:
irb(main):001:1"amefurashi".delete("aiueo")
but why won't it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提示您
>
的 IRB 行适用于新语句。当提示显示
"
时,这意味着您在一个字符串内,并且 IRB 希望您完成输入文本并用另一个引号结束您的字符串。看起来您正在做的事情是尝试在出现新的 (
>
) 提示之前再次输入您的语句如果您陷入错误语句并想要重新开始,请按
Ctrl-C,然后
输入
,你会得到一个干净的>
提示。The IRB lines that prompt you with
>
are for new statements.When the prompt says
"
instead, that means you are inside a string, and IRB is expecting you to finish entering your text and close your string with another quotation mark.It looks like what you are doing is trying to enter your statement again, before you get a new (
>
) prompt.If you are stuck in the middle of an incorrect statement and want to start over, press
Ctrl-C
, thenEnter
and you will get a clean>
prompt.