From: Daniel Berger Date: 2003-04-10T01:26:14+09:00 Subject: Re: Proc Question Travis Whitton wrote: > > As I was coding this morning, a question occured to me. Why must proc objects > have a call method? I'm sure that there's a good reason for this, but it seems > like it would be more natural for proc objects to behave as regular methods > do and avoid the .call() syntax. > > I.e., > square = proc {|n| n * n} > square(4) # => 16 > > I see that [] is aliased to .call, but I find that surprising over (), which > is the more typical way of specifying arguments to a method. Perhaps having > a call method is a more object-oriented way of using proc objects? > > Thanks, > Travis What if you had: def square(n) puts "in the method..." n * n end square = proc{ |n| n * n } square(4) # call method square.call(4) # call proc object In this case, call() would allow you to differentiate between a method and a proc object. Regards, Dan -- a = [74, 117, 115, 116, 32, 65, 110, 111, 116, 104, 101, 114, 32, 82] a.push(117,98, 121, 32, 72, 97, 99, 107, 101, 114) puts a.pack("C*")