mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
62 lines
645 B
CoffeeScript
62 lines
645 B
CoffeeScript
a: [(x) -> x, (x) -> x * x]
|
|
|
|
puts a.length is 2
|
|
|
|
|
|
regex: /match/i
|
|
words: "I think there is a match in here."
|
|
|
|
puts !!words.match(regex)
|
|
|
|
|
|
neg: (3 -4)
|
|
|
|
puts neg is -1
|
|
|
|
|
|
func: ->
|
|
return if true
|
|
|
|
puts func() is null
|
|
|
|
|
|
str: "\\"
|
|
reg: /\\/
|
|
|
|
puts reg(str) and str is '\\'
|
|
|
|
|
|
i: 10
|
|
while i -= 1
|
|
|
|
puts i is 0
|
|
|
|
|
|
money$: 'dollars'
|
|
|
|
puts money$ is 'dollars'
|
|
|
|
|
|
puts {a: (num) -> num is 10 }.a 10
|
|
|
|
|
|
bob: {
|
|
name: 'Bob'
|
|
greet: (salutation) ->
|
|
salutation + " " + @name
|
|
hello: ->
|
|
@greet "Hello"
|
|
10: 'number'
|
|
}
|
|
|
|
puts bob.hello() is "Hello Bob"
|
|
puts bob[10] is 'number'
|
|
|
|
|
|
obj: {
|
|
'is': -> yes
|
|
'not': -> no
|
|
}
|
|
|
|
puts obj.is()
|
|
puts not obj.not()
|