-
Notifications
You must be signed in to change notification settings - Fork 0
Arrays
Mel Florance edited this page Jul 28, 2020
·
3 revisions
Bird Lang supports dynamic typed arrays to store any of this types:
- Integers
- Floats
- Strings
- Functions
- Arrays
To declare an array, you can use the brackets [] characters:
Example:
> var array = [1, 1.618, "hello", [1, 2, 3, 4, 5]]
[
1,
1.618000,
"hello",
[
1,
2,
3,
4,
5
]
]To access an element stored into an array, use the > character, followed by the index to get:
Example:
> array > 2
"hello"To insert an element to an array, use the < character, followed by the value to store:
Example:
> array < "hi"
[
1,
1.618000,
"hello",
[
1,
2,
3,
4,
5
],
"hi"
]To remove an element to an array, use the - character, followed by the index to remove:
Example:
> array - 3
[
1,
1.618000,
"hello"
]To concatenate an other array, use the + character, followed by the array to concat:
Example:
> [1, 2, 3] + [4, 5, 6]
[
1,
2,
3,
4,
5,
6
]To get the size of an array, you can use the % followed by anything:
Example:
> [1, 2, 3, 4, 5, 6] % 1
6