@ and @@ Values

When @ and @@ are prefixed in front of a name they represent, respectively, that name accessed in self and self.__class.

If they are used all by themselves, they are aliases for self and self.__class.

MoonScript:

assert @ == self
assert @@ == self.__class

Lua:

assert(self == self)
assert(self.__class == self.__class)

For example, a quick way to create a new instance of the same class from an instance method using @@:

MoonScript:

some_instance_method = (...) => @@ ...

Lua:

local some_instance_method
some_instance_method = function(self, ...)
  return self.__class(...)
end

results matching ""

    No results matching ""