Ruby Symbol#to_proc — Don’t Forget It!
This is your code:
<code>puts %w{A B}.collect{|e| e.downcase}.inspect</code>
This is my cooler code:
<code>puts %w{A B}.collect( &:downcase).inspect</code>
This is how the Ruby Extension Project makes it work:
<code>class Symbol
def to_proc
proc { |obj, *args| obj.send(self, *args) }
end
end</code>
This is the explanation.
This is the love (see day 38).
Don’t ever forget this.