Array #
Literal Specific Methods #
first() #
Returns
STRING|ARRAY|HASH|BOOLEAN|INTEGER|NULL|FUNCTION|FILE
Returns the first element of the array. Shorthand for array[0]
π > ["a", "b", 1, 2].first()
=> "a"
index(STRING|ARRAY|HASH|BOOLEAN|INTEGER|NULL|FILE) #
Returns
INTEGER
Returns the index of the given element in the array if found. Otherwise return -1
.
π > ["a", "b", 1, 2].index(1)
=> 2
last() #
Returns
STRING|ARRAY|HASH|BOOLEAN|INTEGER|NULL|FUNCTION|FILE
Returns the last element of the array.
π > ["a", "b", 1, 2].last()
=> 2
size() #
Returns
INTEGER
Returns the amount of elements in the array.
π > ["a", "b", 1, 2].size()
=> 4
uniq() #
Returns
ARRAY|ERROR
Returns a copy of the array with deduplicated elements. Raises an error if a element is not hashable.
π > ["a", 1, 1, 2].uniq()
=> [1, 2, "a"]
yeet() #
Returns
STRING|ARRAY|HASH|BOOLEAN|INTEGER|NULL|FUNCTION|FILE
Removes the last element of the array and returns it.
π > a = [1,2,3]
=> [1, 2, 3]
π > a.yeet()
=> 3
π > a
=> [1, 2]
yoink(STRING|ARRAY|HASH|BOOLEAN|INTEGER|NULL|FUNCTION|FILE) #
Returns
NULL
Adds the given object as last element to the array.
π > a = [1,2,3]
=> [1, 2, 3]
π > a.yoink("a")
=> null
π > a
=> [1, 2, 3, "a"]
Generic Literal Methods #
methods() #
Returns
ARRAY
Returns an array of all supported methods names.
π > "test".methods()
=> [count, downcase, find, reverse!, split, lines, upcase!, strip!, downcase!, size, plz_i, replace, reverse, strip, upcase]
type() #
Returns
STRING
Returns the type of the object.
π > "test".type()
=> "STRING"
wat() #
Returns
STRING
Returns the supported methods with usage information.
π > true.wat()
=> BOOLEAN supports the following methods:
plz_s()