Coffeescript“@”变量

Tal*_*uck -1 coffeescript

在 Coffeescript 中,当变量名称以“@”符号开头时,这意味着什么?例如,我一直在查看 hubot 源代码,就在我查看的前几行中,我发现

class Brain extends EventEmitter
  # Represents somewhat persistent storage for the robot. Extend this.
  #
  # Returns a new Brain with no external storage.
    constructor: (robot) ->
    @data =
      users:    { }
      _private: { }

    @autoSave = true

    robot.on "running", =>
      @resetSaveInterval 5
Run Code Online (Sandbox Code Playgroud)

我在其他地方也看到过,但没能猜出它的意思。

Jor*_*bot 5

正如您在运算符和别名中看到的那样,该@符号是 的快捷方式。this

作为 的快捷方式this.property,您可以使用@property.