52

当我在 coffeescript 交互模式下输入 multiline 时,出现错误。

例如,我想尝试以下代码:

kids =
  brother:
    name: "Max"
    age:  11
  sister:
    name: "Ida"
    age:  9

显示此错误:

coffee> kids = 
Error: In repl, Parse error on line 1: Unexpected 'TERMINATOR'
  at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
  at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
  at /usr/lib/coffeescript/coffee-script.js:26:22
  at Object.eval (/usr/lib/coffeescript/coffee-script.js:64:17)
  at Interface.<anonymous> (/usr/lib/coffeescript/repl.js:18:26)
  at Interface.emit (events:27:15)
  at Interface._ttyWrite (readline:309:12)
  at Interface.write (readline:147:30)
  at Stream.<anonymous> (/usr/lib/coffeescript/repl.js:35:17)
  at Stream.emit (events:27:15)

我尝试使用 '\' 作为换行符,但显示了相同的错误。

coffee> kids = \
Error: In repl, Parse error on line 1: Unexpected '\'
  at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
  at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
  at /usr/lib/coffeescript/coffee-script.js:26:22
  at Object.eval (/usr/lib/coffeescript/coffee-script.js:64:17)
  at Interface.<anonymous> (/usr/lib/coffeescript/repl.js:18:26)
  at Interface.emit (events:27:15)
  at Interface._ttyWrite (readline:309:12)
  at Interface.write (readline:147:30)
  at Stream.<anonymous> (/usr/lib/coffeescript/repl.js:35:17)
  at Stream.emit (events:27:15)

我不能使用多行,所以我不能使用缩进。

我该怎么办?

我的环境如下:

  • 操作系统:Ubuntu 10.04 清醒

  • coffeescript 1.0.0 版我用 PPA 和 apt-get 命令安装了 coffeescript。

看到这个网址:https ://launchpad.net/~gezakovacs/+archive/coffeescript

4

2 回答 2

118

您也可以使用Ctrl+V切换到多行模式。

于 2013-01-26T18:33:30.547 回答
1

反斜杠适用于我的咖啡 1.2.1...尝试升级:)

于 2012-05-08T04:15:49.730 回答