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
|
|
|
|
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"
|
|
|
|
|
|
|
|
|