On 5 June 2014 11:53, Stu <stu / rubyprogrammer.net> wrote:

>
> Now if ruby allowed lambda to be the (arg . body) of a def we could have a
> even more fun! Then again writing our own defn probably wouldn't be
> terribly difficult.
>
>
irb(main):001:0> RUBY_VERSION
=> "1.9.3"
irb(main):002:0> class Foo; end
=> nil
irb(main):003:0> sheep = -> { 'bah bah bah!' }
=> #<Proc:0x0000000256e170@(irb):3 (lambda)>
irb(main):004:0> Foo.send :define_method, :bar, &sheep
=> #<Proc:0x00000002539948@(irb):3 (lambda)>
irb(main):005:0> Foo.new.bar
=> "bah bah bah!"

Also works in 2.2.0 (trunk), and everywhere in between. ;)

-- 
  Matthew Kerwin
  http://matthew.kerwin.net.au/