From: Morton Goldberg Date: 2006-08-02T23:02:54+09:00 Subject: Re: Different semantics of Proc and method call -- bug or feature? This _is_ strange. R. Klemme's explanation is enlightening, but now I wonder why qq in the following works like a method definition rather than like pp? #! /usr/bin/ruby -w pp = Proc.new do |arg, *args| p [arg, args] end qq = lambda do |arg, *args| p [arg, args] end s = 1 v = [2] puts VERSION => 1.8.2 pp.call s => [1, []] pp.call v => [2, []] pp.call v, v => [[2], [[2]]] qq.call s => [1, []] qq.call v => [[2], []] qq.call v, v => [[2], [[2]]] Regards, Morton On Aug 2, 2006, at 8:35 AM, Tammo Freese wrote: > Hi all, > > > I stumbled over the following difference between method calls and > Proc calls: > > require 'pp'; > > def a_method(arg, *args) > arg > end > > a_proc = Proc.new do | arg, *args | > arg > end > > pp a_method(1) # => expected 1, got 1 > pp a_proc.call(1) # => expected 1, got 1 > > pp a_method([1]) # => expected [1], got [1] > pp a_proc.call([1]) # => expected [1], got 1 <== ?! > > > I would expect that method calls and proc calls do not differ in > such a way. > Is this a bug or a feature? > > > Thanks for your help, > > Tammo >