Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

101 lines (89 sloc) 1.865 kb
# Boolean Literals
# (Superset of JavaScript)
true
false
on
off
yes
no
# Number Literals
# (Same as JavaScript)
0xff0088
523
0XFFEE33
123.32
-0.32
0.234
6.02e23
6.02E23
# String Literals
# Single quote only, but with heredoc style added
# Heredoc contents don't include opening line and
# are left trimmed to match closing triplet.
'Hello \'World\''
'''
Hello "World"
In 'Multi' lines
'''
# Interpolated literals
# Double quotes and double heredoc
# Values are replaced last minute by a smart agent.
# (SQL escaper, HTML escape)
"Hello $planetoid"
SQL"""
SELECT * FROM users
WHERE name = $name
"""
HTML"<h$l>$title</h$l>"
# http://google-caja.googlecode.com/svn/changes/mikesamuel/string-interpolation-29-Jan-2008/trunk/src/js/com/google/caja/interp/index.html
# Interpolated use cases
"$noun :verb"
#-> String.interpolate(noun, " ", verb)
#=> "World Greets"
SQL"SELECT * FROM users WHERE name=$name"
#-> SQL.interpolate("SELECT * FROM users WHERE name=", name)
#=> "SELECT * FROM users WHERE name='O''Connor'"
JSON"{name: ${data.name}, age: ${data.age}"
#-> JSON.interpolate("{name: ", name, ", data.age: ", data.age}")
#=> "{name: "Tim", age: 27}"
# Regular Expression literals
/123/g
/^([^a-z]+)$/i
# List Literals
[ 1, 2, 3, 4 ]
[
1,0,0
0,1,0
0,0,1
]
# Object Literals
{name="Tim" age=27}
{
name="Tim"
age=27
}
# Delegated Objects
# Creates a new object that inherits from the given
# prototype, and then overrides some properties.
{Animal name="George" color="Brown"}
{Animal
name="George"
color="Brown"
}
# Delegated Lists
# Creates a clone of the passed in List-like object
# but replaces the contents with that given.
[HTMLColors 0x000000, 0xff8800, 0x0088ff, 0x887788]
[HTMLColors
0x000000
0xff8800
0x0088ff
0x887788
]
# Function literal
fun x -> true
# Block Function
fun x, y ->
x
y
end
Jump to Line
Something went wrong with that request. Please try again.