Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Better than methodphitamine?

Original discussion here: http://jicksta.com/articles/2007/08/04/the-methodphitamine

I think this one is prettier (but maybe not as sophisticated):

   1  
   2  module Enumerable
   3    def method_missing(sym, *args)
   4      if (sym.to_s =~ /^(.+)_with$/) && (msg = args.shift)
   5        send($1.to_sym) do |x|
   6          x.send(msg, *args)
   7        end
   8      end
   9    end
  10  end
  11  
  12  [1, 2, 3].map_with :to_s
  13  
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS