Skip to content

Instantly share code, notes, and snippets.

@kidapu
Last active February 9, 2016 18:26
Show Gist options
  • Save kidapu/4fab5484155649b67290 to your computer and use it in GitHub Desktop.
Save kidapu/4fab5484155649b67290 to your computer and use it in GitHub Desktop.
the way to require class in moonscript (this syntax is depreciated)
require "test"
a = test.AClass()
a\update()
a\update()
a\print()
module "test", package.seeall
export AClass
class AClass
new: =>
@aa = 0
update: =>
@aa += 1
@aa
print: =>
print @aa
@Saqoosha
Copy link

Saqoosha commented Feb 9, 2016

module は Lua 5.2 で deprecated になってるので、こっちの手法で http://www.luafaq.org/#T8.1.5

@kidapu
Copy link
Author

kidapu commented Feb 9, 2016

ありがとうございます。近い記事を見つけました。 https://coronalabs.com/blog/2011/09/05/a-better-approach-to-external-modules/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment