Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guide:aya_yaya:array_levidre [2022/09/20 02:05] – fix broken links ulde3 | guide:aya_yaya:array_levidre [2023/12/04 05:54] (current) – Add self-link to stop this from showing as an orphan ulde3 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Arrays (Levidre)====== | + | #REDIRECT guide:array |
- | <WRAP right> | + | |
- | ^ Arrays | + | |
- | ^Type|Guide| | + | |
- | ^Category|AYA/ | + | |
- | ^Author(s)|[[dev:Levidre]]| | + | |
- | ^Published|Unknown| | + | |
- | /*^Last updated||*/ /*Uncomment if you update your guide, and add the date it was last updated*/ | + | |
- | /*| Edits & additions welcome | + | |
- | </ | + | |
- | + | <wrap hide> | |
- | An array is like a table. It has lines and elements. We can access the lines/ | + | |
- | + | ||
- | The arrays are the only variables needing to be initialized before having a value affected. They are initialized by 'array = IARRAY' | + | |
- | + | ||
- | A simple array would be anarray = (" | + | |
- | <code>anarray = IARRAY | + | |
- | anarray[0] = " | + | |
- | anarray[1] = " | + | |
- | + | ||
- | So here is an array of two elements, it is initialized and then the two elements are added. In the ' | + | |
- | + | ||
- | If the number of elements inside the array is unknown, a new element can be added by **anarray = (anarray," | + | |
- | + | ||
- | The foreach [[guide: | + | |
- | + | ||
- | =====One dimension arrays===== | + | |
- | There are two types of arrays with one dimension but all the array with two dimensions are the same. | + | |
- | ====The string arrays==== | + | |
- | A big string with ',' | + | |
- | + | ||
- | This type of array doesn' | + | |
- | + | ||
- | ====The " | + | |
- | They need to be initialized and are the (" | + | |
- | + | ||
- | =====Two dimensions arrays===== | + | |
- | They are a mix between normal and string arrays. They are a normal array which elements are strings or string arrays. They are harder to handle. Foreach loops would work only for one dimension, the " | + | |
- | + | ||
- | A two dimension array looks like this : | + | |
- | < | + | |
- | anarray = IARRAY | + | |
- | anarray[0] = " | + | |
- | anarray[1] = " | + | |
- | </ | + | |
- | + | ||
- | It can be written : | + | |
- | < | + | |
- | anarray = IARRAY | + | |
- | anarray = (" | + | |
- | </ | + | |
- | To access an element, anarray[index1][index2] would be used. So here anarray[0][1] would be " | + | |
- | + | ||
- | But the way of modifying the elements inside the strings of the array is different. To modify it, the string must be taken, modified, and then put back into the array : | + | |
- | < | + | |
- | anarray = (" | + | |
- | astring = anarray[0] | + | |
- | astring[1] = " | + | |
- | anarray[0] = astring</code> | + | |
- | The first line of the array is now " | + | |
- | + | ||
- | + | ||
- | Arrays are very useful to stock data and to do some complicated stuffs. | + |