From: Matthew Smillie Date: 2005-12-09T01:11:56+09:00 Subject: Re: Are my metaprogramming underpants showing? On Dec 8, 2005, at 6:35, Daniel Sheppard wrote: > Considering that there seems to be at least one mandatory argument > (api_key), you could do: > > require 'calibre/functor' > > functor_factory = lambda { |*symbols| > Functor.new { |op, *args| > new_sym = symbols+[op] > # if args.empty?... > } > } > Flickr = functor_factory[] > > Flickr.test.echo.momma("api_key" => "something long", "foo" => "bar") > Maybe this makes me sound thick, but then again, enlightenment is the reason I'm posting. Given that the code below is functionally equivalent, what's beneficial about using a lambda expression? It strikes me as a requirement imposed by using the Functor class more than anything. class Flickr def initialize (method = ['flickr']) @method = method end def method_missing(method_id, *params) new_method = @method + [method_id] if params.empty? self.class.new(new_method) else puts "call: http://flickr.com/services/rest/method=# {new_method.join('.')}" p params end end end flickr = Flickr.new flickr.test.echo.momma("api_key" => "something long", "foo" => "bar") thanks again for the input, matthew smillie. ---- Matthew Smillie Institute for Communicating and Collaborative Systems University of Edinburgh