I have a class that extends Hash, and I want to track when a hash key is modified.
What’s the right syntax to override the [key]= syntactic method to accomplish this? I want to insert my code, then call the parent method.
Is this possible with the C methods? I see from the docs that the underlying method is
rb_hash_aset(VALUE hash, VALUE key, VALUE val)
How does that get assigned to the bracket syntax?
The method signature is
def []=(key, val), andsuperto call the parent method. Here’s a full example: