Being able to pick information out of a hash is nice but what about when you need to update the hash or combine/merge it with another?
ruleset a60x519 {
meta {
name "hash-put-test"
description <<
hash-put-test
>>
author "Mike Grace"
logging on
}
rule testing {
select when pageview ".*"
pre {
first = {
"wow":"yes",
"cool":"yes"
};
second = {
"name":"mike",
"location":"??"
};
combined = first.put(second);
}
{
emit <|
console.log(first);
console.log(second);
console.log(combined);
|>;
}
}
}
- 14-21 generic hashes with dummy data
- 23 merge the two hashes together using the put operator – returns a new hash
- 26-30 output the hashes to the console to review the results
App run on example.com with bookmarklet
Get the bookmarklet to try it out yourself!
Gratuitous day 25 Grace face

