Correct me if I'm wrong, but [1, 2, 3, 4, 5].select(&:even?) should actually be slower than explicitly writing a block, as it creates a Proc object implicitly by calling to_proc on the Symbol. There might of course be some optimization going on in the background that I don't know about. (EDIT: I totally agree that it looks neater though, and I use it a lot myself)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Correct me if I'm wrong, but
[1, 2, 3, 4, 5].select(&:even?)
should actually be slower than explicitly writing a block, as it creates a Proc object implicitly by callingto_proc
on the Symbol. There might of course be some optimization going on in the background that I don't know about. (EDIT: I totally agree that it looks neater though, and I use it a lot myself)