| 1 |
// declare regular array (capacity doesn't matter so much) |
| 2 |
float foo[4]; |
| 3 |
|
| 4 |
// use as int-based array |
| 5 |
2.5 => foo[0]; |
| 6 |
|
| 7 |
// use as associative array with key "yoyo" |
| 8 |
4.0 => foo["yoyo"]; |
| 9 |
|
| 10 |
// access as associative (print) |
| 11 |
<<< foo["yoyo"] >>>; |
| 12 |
|
| 13 |
// access empty element |
| 14 |
<<< foo["gaga"] >>>; // -> should print 0.0 |
| 15 |
|
| 16 |
// add a second associative element |
| 17 |
44.0 => foo["yiyi"]; |
| 18 |
|
| 19 |
// get the array keys with all of the keys in the array |
| 20 |
string keys[0]; |
| 21 |
foo.getKeys(keys); |
| 22 |
|
| 23 |
// print all keys current in foo |
| 24 |
for( auto key : keys ) |
| 25 |
{ |
| 26 |
<<< "key:", key >>>; |
| 27 |
} |
| 28 |
|
| 29 |
// isInMap |
| 30 |
<<< "(isInMap?)", |
| 31 |
"\nyiyi:", foo.isInMap("yiyi"), |
| 32 |
"\nyoyo:", foo.isInMap("yoyo"), |
| 33 |
"\ngaga:", foo.isInMap("gaga"), |
| 34 |
"\nNONO:", foo.isInMap("NONO") >>>; |
| 35 |
|
| 36 |
// call .help() on an array to get more information about its type, methods, etc. |
| 37 |
// foo.help(); |