Coffeescript cli 不断为循环提供意外的输入结束
Coffeescript cli keeps giving unexpected end of input for loops
我决定学习 coffeescript。今天下载了它,并在 cli 中使用它,但我不断收到此处工作的基本代码的奇怪错误:https://coffeescript.org/#try:for%20i%20in%20%5B0..5%5D%0A%20%20%20%20console.log%20%22Hello%20%22%20%2B%20i%20
这里有一个例子:
>coffee -v
CoffeeScript version 2.3.2
>coffee -c
coffee> for i in [0..5]
[stdin]:1:16: error: unexpected end of input
基本上
for i in [0..5]
returns 错误:
[stdin]:1:16: error: unexpected end of input
尽管它在 coffescript 网站上工作得很好
cli版本有问题吗?
您需要在 CLI 中进入多行输入模式才能创建任何需要缩进的代码块。
进入 CLI 后使用 CTRL
+ v
(如果您使用 shell / CMD 用于粘贴,请尝试 CTRL
+ SHIFT
+ v
您应该会看到提示从 coffee>
更改为 ------>
。
不要忘记在 for 循环内部使用缩进。
完成块后,点击 ENTER
并使用 CTRL
+ v
执行多行块。
示例:
在正常模式下编写循环会引发错误
coffee> for i in [1,2,3]
[stdin]:1:17: error: unexpected end of input
for i in [1,2,3]
^
首先进入多行模式(不要忘记首行后缩进)
------> for i in [1,2,3]
....... i * i - i
现在点击进入并退出多行模式来执行。与 CLI 中的任何执行一样,将打印表达式(在本例中为循环)的输出:
[ 0, 2, 6 ]
我决定学习 coffeescript。今天下载了它,并在 cli 中使用它,但我不断收到此处工作的基本代码的奇怪错误:https://coffeescript.org/#try:for%20i%20in%20%5B0..5%5D%0A%20%20%20%20console.log%20%22Hello%20%22%20%2B%20i%20
这里有一个例子:
>coffee -v
CoffeeScript version 2.3.2
>coffee -c
coffee> for i in [0..5]
[stdin]:1:16: error: unexpected end of input
基本上
for i in [0..5]
returns 错误:
[stdin]:1:16: error: unexpected end of input
尽管它在 coffescript 网站上工作得很好
cli版本有问题吗?
您需要在 CLI 中进入多行输入模式才能创建任何需要缩进的代码块。
进入 CLI 后使用 CTRL
+ v
(如果您使用 shell / CMD 用于粘贴,请尝试 CTRL
+ SHIFT
+ v
您应该会看到提示从 coffee>
更改为 ------>
。
不要忘记在 for 循环内部使用缩进。
完成块后,点击 ENTER
并使用 CTRL
+ v
执行多行块。
示例:
在正常模式下编写循环会引发错误
coffee> for i in [1,2,3]
[stdin]:1:17: error: unexpected end of input
for i in [1,2,3]
^
首先进入多行模式(不要忘记首行后缩进)
------> for i in [1,2,3]
....... i * i - i
现在点击进入并退出多行模式来执行。与 CLI 中的任何执行一样,将打印表达式(在本例中为循环)的输出:
[ 0, 2, 6 ]