Civet
Civet copied to clipboard
Semiautovivification
It's nice to have Semiautovivification from livescript
We can currently do something similar with:
x = {}
(x.'hello world' ?= []).2 = 3
I'm not convinced that an additional specialized syntax is worth it in this case.
I just used it a lot in past. Quite elegant. How do we do this
x.[]arr.{}1.y = 9
in Civet way?
Currently:
( ( x.arr ?= [] )[1] ?= {} ).y = 9
It may make sense to try something like this for a possible future syntax:
x.arr?=[][1]?={}.y = 9
Now that we have pipes:
x |> .foo ?= [] |> .append 5
x |> .foo ?= {} |> &[key] ?= [] |> .push value
(x.foo ??= []).append(5);
((x.foo ??= {})[key] ??= []).push(value);