webclient icon indicating copy to clipboard operation
webclient copied to clipboard

Collections accessors and mutators

Open nitzantomer opened this issue 7 years ago • 1 comments

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"

nitzantomer avatar Mar 08 '17 00:03 nitzantomer

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?

creativeChips avatar Mar 25 '17 18:03 creativeChips