I am a stalwart follower of the PEEPCODE screencasts.
I particularly liked the series about RSPEC.
But, in reviewing the code for it, and using the code subsequently, I found this little gem.
class Hash def except(*keys) self.reject{|k, v| keys.include?(k || k.to_sym)} end end
Now, I don’t know where this code came from, but its wrong.
WRONG, WRONG WRONG…
that “keys.include?(a || b)”, I see that, and know exactly what it WANTS to do, but it does not do it.
it will NOT return true if either a or b is in the keys, it WILL return true if a is in keys or a is null and b is in keys.
to get the desired effect you would have to
‘keys.include?(a) || keys.include?(b)’
not as pretty, and my mind says that it likes the other version, but that does not stop it being WRONG.
Anyway, go to Peepcode, buy screencasts and marvel at the information density.