假设我在咖啡脚本文件中有这个功能
test = (arr, fn) ->
console.log item for item in arr
fn()
我是这样称呼它的
test [1, 2, 3, 4, 5], ->
console.log "start"
# function body
console.log "finish"
一切正常,直到数组变得太长,我想把它分成几行。像这样
test ["first element here",
"second element here",
"third element here",
"fourth element here",
"fifth element here"], ->
console.log "start"
# function body
console.log "finish"
这是有效的,因为咖啡脚本编译器完全按照我的预期编译它,但 IDEA 说行中有Unexpected 缩进。console.log "start"
我按Ctrl+Alt+L,IDEA 给了我这个
test ["first element here",
"second element here",
"third element here",
"fourth element here",
"fifth element here"], ->
console.log "start"
# function body
console.log "finish"
这是错误的,因为在这种情况下,空函数作为参数传递。这是一个错误还是我可以自己修复它?