Skip to content

Searching or removing items in a list

bartbutenaers edited this page Aug 16, 2018 · 1 revision

Once a list has been created and filled with items, it is now time to try finding items in that list. Blockly offers multiple ways to do that.

The first way is to find an item based on its position in the list. The following animation shows how the third item 'Item 3' can be searched:

blockly_list_find

From the dropdown it appears that you can search on different types of locations ('#' is the 'index'):

image

Moreover it also possible to remove the item at that location:

image

The second way is the opposite of the first one: find the position of an item in the list, based on its value. The following animation shows how to find the location of 'Item 4' in the list:

blockly_list_findindex

It is also possible to find multiple items at once, by getting the sub-list between to specified locations. The following animation explains how to get all items from the list, between position 2 and position 4:

blockly_sublist