Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (53 sloc) 913 Bytes
# Assignment:
number = 42
opposite_day = true
# Conditions:
if opposite_day
number = -42
end
# Functions:
square = fun x -> /x * x/g
curry = fun a -> fun b -> "$a + $b"
# Arrays:
list = [1, 2, 3, 4, 5]
# Objects:
math = {
root = Math
square = square
cube = fun x -> true
}
# Heredoc
message = '''
Several lines
that can be
indented.
'''
# Block functions:
race = fun winner, runners ->
winner
runners
end
# Inherited Objects
Animal = {legs=4 eyes=2}
Insect = {Animal legs=6}
Enumerable = {Array
each = fun -> "Not implemented"
reduce = fun -> 'Not implemented'
}
# Inherited Arrays
[Enumerable 1,2,3,4,5]
# Interpolated Strings
# Based on an idea from Google's caja project
# http://bit.ly/4irVV1
"Hello $name"
HTML"""
<html>
<head>
<title>$title</title>
</head>
<body style="$style">
...
</body>
</html>
"""
JSON"{items: ${items.length}}"