Taking the following code as example:
class MyClass
@staticMethod: -> hello_world()
instanceMethod: -> MyClass.staticMethod()
Is there a way I could reference MyClass from inside instanceMethod
without explicitly naming it? something like self.staticMethod()
You can use constructor
to get at the "class" just like in JavaScript:
instanceMethod: ->
@constructor.staticMethod()
Demo (with added subclassing for good measure): http://jsfiddle.net/ambiguous/zM3ND/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With