odd=(num)->
if typeof num is 'number'
if num is Math.round num
if num > 0
num % 2 is 1
else
throw "#{num} is not positive"
else
throw "#{num} is not an integer"
else
throw "#{num} is not a number"
总是报这个错误
C:\>coffee odd.coffee
odd.coffee:2:5: error: unexpected POST_IF
if typeof num is 'number'
^^
来给我些关怀吧
odd=(num)->
if typeof num is 'number'
if num is Math.round num
if num > 0
num % 2 is 1
else
throw "#{num} is not positive"
else
throw "#{num} is not an integer"
else
throw "#{num} is not a number"
odd=(num)->
if typeof num is 'number'
if num is Math.round num
if num > 0
num % 2 is 1
else
throw "#{num} is not positive"
else
throw "#{num} is not an integer"
else
throw "#{num} is not a number"
哦,应该是你没有排好
我什么都没动 刚才还好用 然后再试 又报下面的错误
ReferenceError: odd is not defined
at repl:1:5
at REPLServer.replDefaults.eval (C:\Documents and Settings\Administrator\App
lication Data\npm\node_modules\coffee-script\lib\coffee-script\repl.js:28:28)
at repl.js:239:12
at Interface.<anonymous> (C:\Documents and Settings\Administrator\Applicatio
n Data\npm\node_modules\coffee-script\lib\coffee-script\repl.js:58:9)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:754:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
哎我去了 弄死我吧
我想我知道错在呢了
C:\>coffee odd.coffee
C:\>coffee
coffee>coffee odd.coffee
ReferenceError: odd is not defined
at repl:1:5
at REPLServer.replDefaults.eval (C:\Documents and Settings\Administrator\App
lication Data\npm\node_modules\coffee-script\lib\coffee-script\repl.js:28:28)
at repl.js:239:12
at Interface.<anonymous> (C:\Documents and Settings\Administrator\Applicatio
n Data\npm\node_modules\coffee-script\lib\coffee-script\repl.js:58:9)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:754:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
coffee>
为什么在文件所在路径 用 coffee odd.coffee 就可用 换成 coffee>执行指令就不可行了呢