我无法在Coffeescript交互模式(REPL)中编写多行代码

时间:2012-05-08 02:37:25

标签: coffeescript multiline interactive read-eval-print-loop

当我在coffeescript交互模式下键入多行时,出现错误。

对于exapmle,我想尝试以下代码。

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)

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

我该怎么办?

我的环境如下

2 个答案:

答案 0 :(得分:118)

您还可以使用 Ctrl + V 切换到多线模式。

答案 1 :(得分:1)

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