Array Transformer
Array transformers can be used on a value data type of Array, including arrays coming from other transformers, such as by using dot notation on a dictionary. Note that all indexes used in dictionaries start from 0. Following transformers are available:


Returns the first element in the array.
  • Usage: .first()
  • Example usage: array.first()
  • Example: ["bob", "dan", "oleg"] to bob


Returns first N elements of the array. If the array is not sufficiently long, will return the entire array.
  • Usage: .until(n)
  • Example usage: array.until(2)
  • Example: ["bob", "dan", "oleg"] to ["bob", "dan"]


Returns the last element in the array.
  • Usage: .last()
  • Example usage: array.last()
  • Example: ["bob", "dan", "oleg"] to oleg


Returns array starting from the Nth element. If the index is beyond bounds, will return an empty array.
  • Usage: .from(n)
  • Example usage: array.from(1)
  • Example: ["bob", "dan", "oleg"] to ["dan", "oleg"]


Returns the Nth element of the array.
  • Usage: .at(n)
  • Example usage: array.at(1)
  • Example: ["bob", "dan", "oleg"] to dan


Returns N elements of the array, starting at index M. If the array is not sufficiently long, will be trimmed from the end.
  • Usage: .range(n, m)
  • Example usage: array.range(1, 1)
  • Example: ["bob", "dan", "oleg"] to ["bob"]


Returns a random element of the array.
  • Usage: .random()
  • Example usage: array.random()
  • Example: ["bob", "dan", "oleg"] to bob or any other element, based on your luck :)


Returns shuffled array.
  • Usage: .shuffled()
  • Example usage: array.shuffled()
  • Example: ["bob", "dan", "oleg"] to ["dan", "oleg", "bob"] or any other combination, based on your luck :)


Returns sorted version of the array. Only works on String or Int arrays, otherwise array remains the same as the source.
  • Usage: .sorted()
  • Example usage: array.sorted()
  • Example: ["bob", "oleg", "dan"] to ["bob", "dan", "oleg"]


Returns reversed version of the array, meaning the first element will be last and vice versa.
  • Usage: .reversed()
  • Example usage: array.reversed()
  • Example: ["bob", "dan", "oleg"] to ["oleg", "dan", "bob"]


Returns dictionary with index-based keys and values of source array. This is very useful for loops to obtain index alongside data for each cycle. Enumeration index starts with 0.
  • Usage: .enumerated()
  • Example usage: array.enumerated()
  • Example: ["bob", "dan"] to [0: "oleg", 1: "dan"]


Returns array with one additional item pushed into it.
  • Usage: .append(item)
  • Example usage: array.append("dan")
  • Example: ["bob"] to ["bob", "dan"]


Returns string that is made by joining all other strings inside an array, joined by a separator. Will throw an error when the array contains something else than just strings.
  • Usage: .join(separator)
  • Example usage: array.join(", ")
  • Example: ["bob", "dan"] to "bob, dan"


Returns array joined with another array.
  • Usage: .concat(array)
  • Example usage: array.contact(["dan"])
  • Example: ["bob"] + ["dan"] to ["bob", "dan"]


Returns the size of the array.
  • Usage: .count()
  • Example usage: array.count()
  • Example return: ["bob", "dan", "oleg"] to 3
Last modified 7mo ago