Mike, after the hit, I'll make time to create a keys () statement for the hashes.
In the meantime, what I did to get around this is to keep a separate array of keys. That way, I can use the map, filter, and all installed operations on the index, and then use these values ββas my keys for hash operations
key_array = ["key1","key2","key3"]; my_hash = { "key1" : "value1", "key2" : "value2", "key3" : "value3" };
This really only works if you control the values ββin the hash, but here is a sample code:
global { kvHash = { "key1" : "value1", "key2" : "value2", "key3" : "value3" }; kArray = ["key1","key2","key3"]; } pre { pickKey = kArray[1]; value = kvHash.pick("$.#{pickKey}"); // add a new value newKey = "key4"; newVal = "value4"; newArray = kArray.union(newKey); newHash = kvHash.put([newKey],newVal); }
Noticed that I used the set union operator so that the array has unique values
Created javascript shows what it does:
var pickKey = 'key2'; var value = 'value2'; var newKey = 'key4'; var newVal = 'value4'; var newArray = ['key1', 'key2', 'key3', 'key4']; var newHash = {'key2' :'value2','key1' :'value1','key4' :'value4','key3' :'value3'};
Now you can use map or filter to pass each value individually to a function
c.map(function(x){x+2}) c.filter(function(x){x<5})