Skip to content
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

Array declaration

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
    ]
]

Array access

To access an element stored into an array, use the > character, followed by the index to get:

Example:

> array > 2
"hello"

Array insert

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"
]

Array remove

To remove an element to an array, use the - character, followed by the index to remove:

Example:

> array - 3
[
    1,
    1.618000,
    "hello"
]

Array concat

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
]

Array size

To get the size of an array, you can use the % followed by anything:

Example:

> [1, 2, 3, 4, 5, 6] % 1
6

Clone this wiki locally