Attributes > Lists


Read our article on Lists for an explanation of these blocks.


Add / Insert

Add Item to List

add-list-block

Adds the given value to the end of the list.

list.push([VALUE]);

Insert Item into List

insert-list-block

Inserts the given value at the specified index of the list. This will push everything at that index and after down one position. The index must be between 0 and (size of list - 1) inclusive.

list.insert([NUMBER], [VALUE]);

Remove

Remove Item from List

remove-item-list-block

Removes the given value from the list, if it exists. If it does not exist, nothing happens.

list.remove([VALUE]);

Remove Item from Index

remove-index-block

Removes the value at the specified index from the list. The index must be between 0 and (size of list - 1) inclusive.

list.splice([NUMBER], 1);

Empty out List

empty-list-block

Removes all values from the list.

Utils.clear(list);

Replace

Replace Item in List

replace-list-block

Replaces the item at the specified index with another for the list. The index must be between 0 and (size of list - 1) inclusive.

list[[NUMBER]] = [VALUE];

Getters

Get Item from Index

get-index-list-block

Returns the item at the specified index in the list. The index must be between 0 and (size of list - 1) inclusive.

list[[NUMBER]]

List contains Item?

contains-list-block

Returns true if the list contains the specified item.

Utils.contains(list, [VALUE])

List Size

size-list-block

Returns the number of items in the list.

list.length

Is List Empty?

is-empty-list-block

Returns true if the list contains no items.

(list.length == 0)

Create / Copy

Create New List

create-list-block

Creates and returns an empty list. Usually, you'll want to set this immediately to a list attribute.

new Array<Dynamic>()

Copy of List

copy-list-block

Returns a shallow copy of the specified list.

list.copy()

Looping

For Each Item in List ...

loop-list-block

Lets you perform logic on each item in the list. Use the embedded item block to retrieve the current item being examined.

for(item in cast(list, Array<Dynamic>)) {
  [ACTIONS]
}