would result in two different criteria, which is not the case. “crit2 is the original criteria where age is 19” makes sense, but I would not expect that to update crit1.
I don’t mind mutability per se, but it needs to be clear what data is mutable and when it is mutated.
It seems obvious to me that this would be how to implement this. When I read his initial code, I immediately wondered why he wasn't returning self.
Maybe this familiarity comes with having spent enough time reading through the jQuery internals. Speaking of which, if you like this article, the classic "10 things I learned from the jQuery source" is great reading:
This is a pretty good bite-size sampling of the workings of some of the nice things we take for granted in Rails (like AREL). Rspec is another one that's worth looking into:
Thanks! I totally agree RSpec's a good library to dive into too. To understand how it works, I wrote Raptor (https://github.com/jeffkreeftmeijer/raptor) a while back. I might write about that too, sometime. :)
I really enjoyed that. It's something I wish I knew early in my Ruby programming experience. I've done similar things on my own but I really appreciated the approach taken here.
I don’t mind mutability per se, but it needs to be clear what data is mutable and when it is mutated.