Method chaining and lazy evaluation in Ruby
jeffkreeftmeijer.com
jeffkreeftmeijer.com
crit1 = Criteria.new.where(:name => 'Jeff')
crit2 = crit1.where(:age => 19)
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.
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:
http://paulirish.com/2010/10-things-i-learned-from-the-jquer...
http://stackoverflow.com/questions/3105755/ruby-metaprogramm...