webclient
webclient copied to clipboard
Collections accessors and mutators
Given a list or map:
arr = [1, 2, 3]
map = {
str: "string",
num: 4
}
There's no way to access the items in the collections.
These should work:
Access:
echo $arr[1]
echo $map.num
Mutate:
$arr[1] = 10
$map.num = "new string"
Question raised is why stop at this? what about $list.length
for example? Do we want to enable running predefined "methods" on built in types? For example set A to $list1.concat($list2)
?
Or should we keep the separation of data and behavior and only expose "commands style" api, like get $arr at 1
and set $arr at 1 to be 10
, or length of $list
?