1 # These are really lists
2
3 #### basic array
4 var x = %(1 2 3)
5 write len=$[len(x)]
6 ## STDOUT:
7 len=3
8 ## END
9
10 #### string array with command sub, varsub, etc.
11 shopt -s oil:all
12
13 var x = 1
14 var a = %($x $(write hi) 'sq' "dq $x")
15 write len=$[len(a)]
16 write @a
17 ## STDOUT:
18 len=4
19 1
20 hi
21 sq
22 dq 1
23 ## END
24
25 #### printing type of array with pp and =
26 var b = %(true)
27 # pp cell should show the type of the object?
28 pp cell b
29 = b
30
31 var empty = %()
32 pp cell empty
33 = empty
34
35 ## STDOUT:
36 Array[Bool]
37 Array[???] # what should this be?
38 ## END
39
40 #### splice and stringify array
41
42 var x = :| 'a b' c |
43
44 argv.py "${x[@]}" # should work
45
46 echo -$x- # fails because it's not an array
47
48 ## STDOUT:
49 ['a b', 'c']
50 2023-06 TODO: should fail
51 ## END