diff options
author | elioat <elioat@tilde.institute> | 2024-10-16 21:53:20 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-10-16 21:53:20 -0400 |
commit | c11f9b8aa27935d911562239b53786cb020e6e00 (patch) | |
tree | 2f02d443c6318230feea36f5a529edf80ff46115 | |
parent | 114472cf357cfd400b92cdfe6973df21288cd805 (diff) | |
download | tour-c11f9b8aa27935d911562239b53786cb020e6e00.tar.gz |
*
-rw-r--r-- | coffee/demo.coffee | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/coffee/demo.coffee b/coffee/demo.coffee new file mode 100644 index 0000000..0db65dd --- /dev/null +++ b/coffee/demo.coffee @@ -0,0 +1,28 @@ +# Assignment: +number = 42 +opposite = true + +# Conditions: +number = -42 if opposite + +# Functions: +square = (x) -> x * x + +# Arrays: +list = [1, 2, 3, 4, 5] + +# Objects: +math = + root: Math.sqrt + square: square + cube: (x) -> x * square x + +# Splats: +race = (winner, runners...) -> + print winner, runners + +# Existence: +alert "I knew it!" if elvis? + +# Array comprehensions: +cubes = (math.cube num for num in list) |