I am trying to add an item into a darray
|> darray(JSON::decodeMap($$))
I want to append one more item
discover_arg => xxxxx in to this darray, how could I achieve so?
I am trying to add an item into a darray
|> darray(JSON::decodeMap($$))
I want to append one more item
discover_arg => xxxxx in to this darray, how could I achieve so?
There is a merge function for dict
s, if you're able to use these instead of darray.
But for the sake of one element on a potentially large array, I wouldn't use it — many of the HSL functions often incur a linear penalty for constant-time/space things. They are immutable functions, and PHP/Hack's collections aren't implemented for fast partial cloning (like linked lists and trees are).
At the risk of muddying the purity of the pipe, especially if you're really setting this element right after generating it, you may just make your own lambda set + return:
|> darray(JSON::decodeMap($$))
|> ((darray<string, string> $d) ==> { $d['discover_arg'] = 'xxxxx'; return $d; })($$)