Ruby Symbol#to_proc — Don’t Forget It!

This is your code:

puts %w{A B}.collect{|e| e.downcase}.inspect

This is my cooler code:

puts %w{A B}.collect( &:downcase).inspect

This is how the Ruby Extension Project makes it work:

class Symbol
  def to_proc
    proc { |obj, *args| obj.send(self, *args) }
  end
end

This is the explanation.

This is the love (see day 38).

Don’t ever forget this.