Skip to content
Johannes Zottele edited this page Sep 19, 2022 · 1 revision

Lists are a generic datastructure and with that an exception as Moose doesn't allow you to define custom generic Classes.


List[T].append(T) > Void

Appends the provided item to the end of the list.

List[T].append(List[T]) > Void

Appends the rest the provided list to the end of the first one.

List[T].enumerated() > List[(Int, T)]

Returns a list where each item is wrapped in a tuple with the first element being the index in the original list and the second being the original item.

List[T].joined() > String

Returns a string of the joined list, where each element is converted to String via its represent() method.

List[T].joined(String) > String

Returns a string of the joined list, where each element is converted to String via its represent() method. In addition the first argument is used as seperator between the joined elements.

List[T].getItem(Int) > T

Returns the item at the provided index.

This method panics with OutOfBoundsPanic if the item at the index doesn't exist.

There is syntactic sugar for this function:

l = [1, 77, 3, 4]
println(l[1])

List[T].setItem(Int, T) > Void

Updates the item at the provided index.

This method panics with OutOfBoundsPanic if the item at the index doesn't exist.

There is syntactic sugar for this function:

l = [1, 77, 3, 4]
l[1] = 2

List[T].length() > Int

Returns the length of the list.

List[T].reverse() > Void

Reverses the List in place.

List[T].reversed() > List[T]

Returns a reversed copy of the list and leaves the original intact.