使用CoffeeScript的.bind函数

Phi*_*ide 1 javascript coffeescript

当我尝试转换以下代码片段时......

result.pause = function() {        
  cachedValue = this();
  isPaused(true);
}.bind(result);
Run Code Online (Sandbox Code Playgroud)

使用http://js2coffee.org/它返回

result.pause = ->
  cachedValue = this()
  isPaused true
.bind(result)
Run Code Online (Sandbox Code Playgroud)

但是,当您尝试编译它时,该代码是不正确的,您将返回Error Unexpected'.'

使用CoffeeScript在这种情况下使用.bind函数的正确方法是什么?

Sup*_*tus 7

result.pause = (->
  cachedValue = this()
  isPaused true)
.bind(result)
Run Code Online (Sandbox Code Playgroud)