1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-21 05:51:31 +02:00

Merge pull request #255 from L8D/patch-1

Updated documentation for new language behavior of Whip
This commit is contained in:
Adam Bard
2013-08-19 08:20:13 -07:00

View File

@@ -109,18 +109,18 @@ undefined ; user to indicate a value that hasn't been set
; Dictionaries are Whip's equivalent to JavaScript 'objects' or Python 'dicts' ; Dictionaries are Whip's equivalent to JavaScript 'objects' or Python 'dicts'
; or Ruby 'hashes': an unordered collection of key-value pairs. ; or Ruby 'hashes': an unordered collection of key-value pairs.
{"key1":"value1" "key2":2 3:3} {"key1" "value1" "key2" 2 3 3}
; Keys are just values, either identifier, number, or string. ; Keys are just values, either identifier, number, or string.
(def my_dict {my_key:"my_value" "my other key":4}) (def my_dict {my_key "my_value" "my other key" 4})
; But in Whip, dictionaries get parsed like: value, colon, value; ; But in Whip, dictionaries get parsed like: value, whitespace, value;
; with whitespace between each. So that means ; with more whitespace between each. So that means
{"key": "value" {"key" "value"
"another key" "another key"
: 1234 1234
} }
; is evaluated to the same as ; is evaluated to the same as
{"key":"value" "another key":1234} {"key" "value" "another key" 1234}
; Dictionary definitions can be accessed used the `at` function ; Dictionary definitions can be accessed used the `at` function
; (like strings and lists.) ; (like strings and lists.)
@@ -220,8 +220,8 @@ undefined ; user to indicate a value that hasn't been set
(max (1 2 3 4)) ; 4 (max (1 2 3 4)) ; 4
; If value is in list or object ; If value is in list or object
(elem 1 (1 2 3)) ; true (elem 1 (1 2 3)) ; true
(elem "foo" {"foo":"bar"}) ; true (elem "foo" {"foo" "bar"}) ; true
(elem "bar" {"foo":"bar"}) ; false (elem "bar" {"foo" "bar"}) ; false
; Reverse list order ; Reverse list order
(reverse (1 2 3 4)) ; => (4 3 2 1) (reverse (1 2 3 4)) ; => (4 3 2 1)
; If value is even or odd ; If value is even or odd