1 | # Test Oil expressions within $[] |
2 | |
3 | #### $[f(x)] |
4 | func f() { |
5 | return 42 |
6 | } |
7 | echo $[f()] |
8 | ## STDOUT: |
9 | 42 |
10 | ## END |
11 | |
12 | #### $[obj.attr] |
13 | var obj = /d+/ |
14 | set obj.x = 42 |
15 | echo $[obj.x] |
16 | ## STDOUT: |
17 | 42 |
18 | ## END |
19 | |
20 | #### $[d['key']] |
21 | var d = @{} |
22 | set d['key'] = 42 |
23 | echo $[d['key']] |
24 | ## STDOUT: |
25 | 42 |
26 | ## END |
27 | |
28 | #### $[d->key] |
29 | var d = @{} |
30 | set d['key'] = 42 |
31 | echo $[d->key] |
32 | ## STDOUT: |
33 | 42 |
34 | ## END |
35 | |
36 | #### In Double quotes |
37 | func f() { return 42 } |
38 | var obj = /d+/ |
39 | set obj.x = 42 |
40 | var d = @{} |
41 | set d['key'] = 42 |
42 | echo "func $[f()]" |
43 | echo "attr $[obj.x]" |
44 | echo "key $[d['key']]" |
45 | echo "key $[d->key]" |
46 | echo "dq $[d["key"]]" |
47 | ## STDOUT: |
48 | func 42 |
49 | attr 42 |
50 | key 42 |
51 | key 42 |
52 | dq 42 |
53 | ## END |