node conversion finished, narwhal removed.

This commit is contained in:
Jeremy Ashkenas
2010-01-29 23:30:54 -05:00
parent e08e99a403
commit f5a37035cf
48 changed files with 208 additions and 357 deletions

View File

@@ -1,8 +1,8 @@
print(if my_special_variable? then false else true)
puts(if my_special_variable? then false else true)
my_special_variable: false
print(if my_special_variable? then true else false)
puts(if my_special_variable? then true else false)
# Existential assignment.
@@ -12,7 +12,7 @@ a: null
a ?= 10
b ?= 10
print a is 10 and b is 10
puts a is 10 and b is 10
# The existential operator.
@@ -20,7 +20,7 @@ print a is 10 and b is 10
z: null
x: z ? "EX"
print z is null and x is "EX"
puts z is null and x is "EX"
# Only evaluate once.
@@ -30,7 +30,7 @@ get_next_node: ->
throw "up" if counter
counter++
print(if get_next_node()? then true else false)
puts(if get_next_node()? then true else false)
# Existence chains, soaking up undefined properties:
@@ -39,17 +39,17 @@ obj: {
prop: "hello"
}
print obj?.prop is "hello"
puts obj?.prop is "hello"
print obj?.prop?.non?.existent?.property is undefined
puts obj?.prop?.non?.existent?.property is undefined
# Soaks and caches method calls as well.
arr: ["--", "----"]
print arr.pop()?.length is 4
print arr.pop()?.length is 2
print arr.pop()?.length is undefined
print arr[0]?.length is undefined
print arr.pop()?.length?.non?.existent()?.property is undefined
puts arr.pop()?.length is 4
puts arr.pop()?.length is 2
puts arr.pop()?.length is undefined
puts arr[0]?.length is undefined
puts arr.pop()?.length?.non?.existent()?.property is undefined