1 | # Test Oil expressions within $[] |
2 | |
3 | #### $[f(x)] |
4 | var a = %(a b c) |
5 | echo $[len(a)] |
6 | ## STDOUT: |
7 | 3 |
8 | ## END |
9 | |
10 | #### $[d['key']] |
11 | var d = {} |
12 | setvar d['key'] = 42 |
13 | echo $[d['key']] |
14 | ## STDOUT: |
15 | 42 |
16 | ## END |
17 | |
18 | #### $[d.key] |
19 | var d = {} |
20 | setvar d['key'] = 42 |
21 | echo $[d.key] |
22 | ## STDOUT: |
23 | 42 |
24 | ## END |
25 | |
26 | #### In Double quotes |
27 | var a = %(a b c) |
28 | var obj = /d+/ |
29 | var d = {} |
30 | setvar d['key'] = 42 |
31 | echo "func $[len(a)]" |
32 | echo "key $[d['key']]" |
33 | echo "key $[d.key]" |
34 | echo "dq $[d["key"]]" |
35 | ## STDOUT: |
36 | func 3 |
37 | key 42 |
38 | key 42 |
39 | dq 42 |
40 | ## END |