summaryrefslogtreecommitdiff
path: root/docs/yaml/elementary/array.yml
blob: 7183d1aff55d5e1f7e8eeeab366144df56f8b0f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: array
long_name: Array
description: An array of elements. See [arrays](Syntax.md#arrays).
is_container: true

methods:
- name: contains
  returns: bool
  description: |
    Returns `true` if the array contains the object
    given as argument, `false` otherwise

  arg_flattening: false

  posargs:
    item:
      type: any
      description: The item to check

- name: get
  returns: any
  description: |
    returns the object at the given index,
    negative indices count from the back of the array, indexing out of
    bounds returns the `fallback` value *(since 0.38.0)* or, if it is
    not specified, causes a fatal error

  arg_flattening: false

  posargs:
    index:
      type: int
      description: Index of the array position to query. Negative values start at the end of the array

  optargs:
    fallback:
      type: any
      description: Fallback value that is returned if the index is out of range.

- name: slice
  returns: array[any]
  since: 1.10.0
  description: |
    Return a selection of the elements of the array starting at index `start`
    and continuing with `step` size jumps until `stop`. Negative indices count
    from the back of the array. The step size cannot be zero, but may be
    negative. If it is negative, `start` and `stop` default to the end and
    beginning of the array, respectively. If `step` is positive, `start`
    defaults to 0 and `stop` defaults to the length of the array. Either both
    or none of `start` and `stop` must be provided to prevent ambiguity.

  optargs:
    start:
      type: int
      description: The lower bound of the slice

    stop:
      type: int
      description: The upper bound of the slice

  kwargs:
    step:
      type: int
      default: 1
      description: The step size

- name: length
  returns: int
  description: Returns the current size of the array.

- name: flatten
  returns: array[any]
  since: 1.9.0
  description: Returns a flattened copy of the array, with all nested arrays removed.