2011-06-15 06:13:33 +00:00
|
|
|
|
|
|
|
class Hello
|
|
|
|
new: (@test, @world) =>
|
|
|
|
print "creating object.."
|
|
|
|
hello: =>
|
|
|
|
print @test, @world
|
|
|
|
__tostring: => "hello world"
|
|
|
|
|
|
|
|
x = Hello 1,2
|
2011-06-23 06:45:03 +00:00
|
|
|
x\hello()
|
2011-06-15 06:13:33 +00:00
|
|
|
|
|
|
|
print x
|
|
|
|
|
2011-06-16 05:41:17 +00:00
|
|
|
class Simple
|
|
|
|
cool: => print "cool"
|
|
|
|
|
|
|
|
class Yikes extends Simple
|
|
|
|
new: => print "created hello"
|
|
|
|
|
|
|
|
x = Yikes()
|
2011-06-23 06:45:03 +00:00
|
|
|
x\cool()
|
2011-06-15 06:13:33 +00:00
|
|
|
|
2011-06-19 19:07:01 +00:00
|
|
|
|
|
|
|
class Hi
|
|
|
|
new: (arg) =>
|
|
|
|
print "init arg", arg
|
|
|
|
|
|
|
|
cool: (num) =>
|
|
|
|
print "num", num
|
|
|
|
|
|
|
|
|
|
|
|
class Simple extends Hi
|
|
|
|
new: => super "man"
|
|
|
|
cool: => super 120302
|
|
|
|
|
|
|
|
x = Simple()
|
2011-06-23 06:45:03 +00:00
|
|
|
x\cool()
|
2011-06-19 19:07:01 +00:00
|
|
|
|
2011-07-04 18:36:26 +00:00
|
|
|
print x.__class == Simple
|
2011-06-19 19:07:01 +00:00
|
|
|
|
2011-08-29 06:19:48 +00:00
|
|
|
|
|
|
|
class Okay
|
|
|
|
-- what is going on
|
|
|
|
something: 20323
|
|
|
|
-- yeaha
|
|
|
|
|
2011-12-03 04:07:42 +00:00
|
|
|
|
|
|
|
class Biggie extends Okay
|
|
|
|
something: =>
|
|
|
|
super 1,2,3,4
|
|
|
|
super.something another_self, 1,2,3,4
|
|
|
|
assert super == Okay
|
|
|
|
|
2011-12-03 04:37:47 +00:00
|
|
|
|
|
|
|
class Yeah
|
|
|
|
okay: =>
|
|
|
|
super\something 1,2,3,4
|
|
|
|
|
2011-12-03 18:39:03 +00:00
|
|
|
|
|
|
|
class What
|
|
|
|
something: => print "val:", @val
|
|
|
|
|
|
|
|
class Hello extends What
|
|
|
|
val: 2323
|
|
|
|
something: => super\something
|
|
|
|
|
|
|
|
with Hello!
|
|
|
|
x = \something!
|
|
|
|
print x
|
|
|
|
x!
|
|
|
|
|
2011-12-03 18:44:41 +00:00
|
|
|
class CoolSuper
|
|
|
|
hi: =>
|
|
|
|
super(1,2,3,4) 1,2,3,4
|
|
|
|
super.something 1,2,3,4
|
|
|
|
super.something(1,2,3,4).world
|
|
|
|
super\yeah"world".okay hi, hi, hi
|
|
|
|
something.super
|
|
|
|
super.super.super.super
|
2015-09-30 07:57:08 +00:00
|
|
|
super\hello
|
2011-12-03 18:44:41 +00:00
|
|
|
nil
|
|
|
|
|
|
|
|
|
2012-01-09 06:02:43 +00:00
|
|
|
-- selfing
|
|
|
|
x = @hello
|
|
|
|
x = @@hello
|
|
|
|
|
|
|
|
@hello "world"
|
|
|
|
@@hello "world"
|
|
|
|
|
|
|
|
@@one @@two(4,5) @three, @four
|
|
|
|
|
|
|
|
xx = (@hello, @@world, cool) ->
|
2011-12-03 18:44:41 +00:00
|
|
|
|
2012-01-09 07:10:25 +00:00
|
|
|
|
|
|
|
-- class properties
|
|
|
|
class ClassMan
|
|
|
|
@yeah: 343
|
|
|
|
blue: =>
|
|
|
|
@hello: 3434, @world: 23423
|
|
|
|
green: =>
|
|
|
|
@red: =>
|
|
|
|
|
|
|
|
|
2012-01-11 06:14:14 +00:00
|
|
|
x = @
|
|
|
|
y = @@
|
|
|
|
|
|
|
|
@ something
|
|
|
|
|
|
|
|
@@ something
|
|
|
|
|
|
|
|
@ = @ + @ / @
|
|
|
|
|
|
|
|
@ = 343
|
|
|
|
@.hello 2,3,4
|
|
|
|
|
|
|
|
hello[@].world
|
|
|
|
|
2012-01-22 19:47:47 +00:00
|
|
|
|
|
|
|
class Whacko
|
|
|
|
@hello
|
|
|
|
if something
|
|
|
|
print "hello world"
|
|
|
|
|
|
|
|
hello = "world"
|
|
|
|
@another = "day"
|
|
|
|
|
|
|
|
print "yeah" if something -- this is briken
|
|
|
|
|
|
|
|
|
|
|
|
print "hello"
|
|
|
|
|
2012-10-30 16:44:02 +00:00
|
|
|
yyy = ->
|
|
|
|
class Cool
|
|
|
|
nil
|
2012-01-22 19:47:47 +00:00
|
|
|
|
2012-10-31 07:07:59 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
class a.b.c.D
|
|
|
|
nil
|
|
|
|
|
|
|
|
|
|
|
|
class a.b["hello"]
|
|
|
|
nil
|
|
|
|
|
|
|
|
class (-> require "moon")!.Something extends Hello.World
|
|
|
|
nil
|
|
|
|
|
2012-11-01 15:56:54 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
a = class
|
|
|
|
b = class Something
|
|
|
|
c = class Something extends Hello
|
|
|
|
d = class extends World
|
2012-10-31 07:07:59 +00:00
|
|
|
|
2012-11-01 15:56:54 +00:00
|
|
|
print (class WhatsUp).__name
|
2012-10-31 20:44:56 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
export ^
|
|
|
|
class Something
|
|
|
|
nil
|
|
|
|
|
|
|
|
|
2013-01-13 22:10:21 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
-- hoisting
|
|
|
|
class Something
|
|
|
|
val = 23
|
|
|
|
{:insert} = table
|
|
|
|
new: => print insert, val -- prints nil 23
|
|
|
|
|
|
|
|
--
|
|
|
|
|
2013-01-24 01:50:36 +00:00
|
|
|
class X
|
|
|
|
new: hi
|
|
|
|
|
2013-01-13 22:10:21 +00:00
|
|
|
nil
|