Array methods
Return the number of elements contained in the target array.
Add an element at the end of an array.
Remove the last element of an array.
Create a new Array with all elements reversed
Add the elements of the array to the initial array
.insert_at(Integer, *)
Add an element at position n of an array (shifting the position of all the following elements).
.remove_at(Integer)
Remove the nth element of an array (unshifting the position of all the following elements).
Returns a new array with all the values found in the original array matching the given value.
You can find more info about the particular regex syntax used in the *_regex methods on .
.to_uppercase()
Return the same string in all uppercase characters.
.to_lowercase()
Return the same string in all lowercase characters.
Return the length of the target string.
.contains(String), .contains_regex(String)
Return whether the string contains another string or expression.
.starts_with(String), .starts_with_regex(String)
Return whether a string starts with another string or expression.
.ends_with(String), .ends_with_regex(String)
Return whether a string ends with another string or expression.
.match(String), .match_regex(String)
Return all the matches of the string or expression in the target string, or Null if none are found.
Create a new array of size n
.slice(start, end)
Return a new array with all items between start and end. Some rules apply:
If end is not specified, all the items after start are returned.
When specified, end must be ≥ start.
.map(fn), .filter(fn), .reduce(acc, fn)
These methods are useful ways to construct a new arrays from existing arrays. They are inspired from similar methods in other languages and follow the same general syntax.
Here are some examples of what these methods can help you achieve:
Convert an array of arrays to an array containing all elements of the 1st level arrays.