2010-07-25 01:23:37 -04:00
|
|
|
area = (x, y, x1, y1) ->
|
2010-02-16 19:38:52 -05:00
|
|
|
(x - x1) * (x - y1)
|
|
|
|
|
2010-07-25 01:23:37 -04:00
|
|
|
x = y = 10
|
|
|
|
x1 = y1 = 20
|
2010-02-16 19:38:52 -05:00
|
|
|
|
2010-04-03 10:39:32 -04:00
|
|
|
ok area(x, y, x1, y1) is 100
|
2010-02-16 19:38:52 -05:00
|
|
|
|
2010-08-08 17:37:28 -04:00
|
|
|
# ok(area(x, y,
|
|
|
|
# x1, y1) is 100)
|
2010-02-16 19:38:52 -05:00
|
|
|
|
|
|
|
ok(area(
|
|
|
|
x
|
|
|
|
y
|
|
|
|
x1
|
|
|
|
y1
|
2010-04-03 10:39:32 -04:00
|
|
|
) is 100)
|
2010-02-16 19:38:52 -05:00
|
|
|
|
|
|
|
|
2010-07-25 01:23:37 -04:00
|
|
|
sumOfArgs = ->
|
|
|
|
sum = 0
|
|
|
|
sum += val for val in arguments
|
2010-03-15 23:46:14 -04:00
|
|
|
sum
|
|
|
|
|
2010-07-28 01:54:36 -04:00
|
|
|
ok sumOfArgs(1, 2, 3, 4, 5) is 15
|
|
|
|
|
|
|
|
|
|
|
|
((@arg) ->).call context = {}, 1
|
|
|
|
ok context.arg is 1
|
|
|
|
|
|
|
|
((splat..., @arg) ->).call context, 1, 2, 3
|
2010-07-28 02:17:50 -04:00
|
|
|
ok context.arg is 3
|
|
|
|
|
|
|
|
((@arg...) ->).call context, 1, 2, 3
|
2010-07-28 07:34:28 -04:00
|
|
|
ok context.arg.join ' ' is '1 2 3'
|
|
|
|
|
|
|
|
class Klass
|
|
|
|
constructor: (@one, @two) ->
|
|
|
|
|
|
|
|
obj = new Klass 1, 2
|
|
|
|
|
|
|
|
ok obj.one is 1
|
|
|
|
ok obj.two is 2
|