Attributes > Lists


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


Create

Create New List

create new list

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 of list

Returns a shallow copy of the specified list.

list.copy()

Add / Insert

Add Item to List

add object to list

Adds the given value to the end of the list.

list.push([VALUE]);

Insert Item into List

insert object at int to list

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([INT], [VALUE]);

Remove / Replace

Remove Item from List

remove object from list

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 item # int from list

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

list.splice([INT], 1);

Replace Item in List

replace item # int with object in list

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[[INT]] = [VALUE];

Empty out List

empty list

Removes all values from the list.

Utils.clear(list);

Access

Get Item from Index

get item # int from list

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

list[[INT]]

Position of Item in List

get position of object in list

Returns the index of the item in the list. If the item is in the list multiple times, this returns the first index found. If the item isn't in the list, this returns -1.

list.indexOf([VALUE])

List contains Item?

list contains object

Returns true if the list contains the specified item.

Utils.contains(list, [VALUE])

List Size

number of items in list

Returns the number of items in the list.

list.length

Is List Empty?

list contains no items

Returns true if the list contains no items.

(list.length == 0)

For Each Item in List ...

for each in list

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]
}