Multidimensional Arrays: различия между версиями
м (Replaced incorrect use of "i.e." with "for example"; added necessary "that") |
Patarakin (обсуждение | вклад) м (1 версия импортирована) |
(нет различий)
|
Текущая версия на 11:33, 21 июля 2022
Шаблон:Merge Шаблон:See also A multidimensional array is an array that contains other arrays of the same length; for example, an array with length 3 that contains 3 arrays, each of length 3. Currently, Scratch does not support such arrays; however, they can be replicated with strings. To do so, one compiles one list into a string (separated by a character such as a semicolon), adds that string as an item to a second list, compiles the second list into another string, and adds that string into a third list, then compiles that third list... and so on, for however many dimensions the array contains.
Tutorial
This tutorial assumes two variables:
It also assumes (assuming this is a 3-dimensional list) three lists:
with "uno" actually storing the data.
Retrieving a value
This process decompiles the lists and retrieves one item, using the three indexes provided.
The variable is the value retrieved.
Storing a value
This process decompiles the lists, changes one value, then recompiles them.