Hash
people = [{"name": "Anna", "age": 24}, {"name": "Bob", "age": 99}];
// reassign of values
h = {"a": 1, 2: true}
puts(h["a"])
puts(h[2])
h["a"] = 3
h["b"] = "moo"
puts(h["a"])
puts(h["b"])
puts(h[2])h = {"a": 1, 2: true}
puts(h["a"])
puts(h[2])
h["a"] = 3
h["b"] = "moo"
// should output
1
true
3
"moo"
true
Literal Specific Methods​
get(INTEGER|STRING|BOOLEAN|ARRAY|HASH|FLOAT|ERROR|NIL, INTEGER|STRING|BOOLEAN|ARRAY|HASH|FLOAT|ERROR|NIL)​
Returns
INTEGER|STRING|BOOLEAN|ARRAY|HASH|FLOAT|ERROR|NIL
Returns the value of the given key or the default
{"a": "1", "b": "2"}.get("a", 10)
{"a": "1", "b": "2"}.get("c", 10)
Output
1
10
include?(BOOLEAN|STRING|INTEGER|FLOAT|ARRAY|HASH)​
Returns
BOOLEAN
Returns true or false wether the hash contains the given object as key
{"a": 1, 1: "b"}.include?(1)
{"a": 1, 1: "b"}.include?("c")
Output
true false
keys()​
Returns
ARRAY
Returns the keys of the hash.
{"a": "1", "b": "2"}.keys()
Output
["a", "b"]
values()​
Returns
ARRAY
Returns the values of the hash.
{"a": "1", "b": "2"}.values()
Output
["1", "2"]
Generic Literal Methods​
methods()​
Returns
ARRAY
Returns an array of all supported methods names.
"test".methods()
Output
["upcase", "find", "format", "reverse", "split", "replace", "strip!", "count", "reverse!", "lines", "downcase!", "upcase!", "size", "plz_i", "strip", "downcase"]
to_json()​
Returns
STRING|ERROR
Returns the object as json notation.
a = {"test": 1234}
a.to_json()
Output
{"test": 1234}
"{\"test\":1234}"
type()​
Returns
STRING
Returns the type of the object.
"test".type()
Output
"STRING"
wat()​
Returns
STRING
Returns the supported methods with usage information.
true.wat()
Output
"BOOLEAN supports the following methods:
plz_s()"