Potentially misleading yes, incorrect no. If you call send on an object you get an object back. It may be the same object, it may be another object. You could say
obj.send(symbol [, args...]) → otherobj
Which would work for your case, but not if the object itself was returned. Take for example:
Somehow, I don't expect the return value of send() to be the receiver.
Let's test send()'s return value using the example provided:
class Klass
def hello(*args)
"Hello " + args.join(' ')
end
end
k = Klass.new
x = k.send :hello, "gentle", "readers"
puts x.class
--output:--
String
According to the docs, the return value of send() should be k, the
receiver, and k.class would therefore output: Klass.
Potentially misleading yes, incorrect no. If you call send on an object you get an object back. It may be the same object, it may be another object. You could say
obj.send(symbol [, args...]) → otherobj
Which would work for your case, but not if the object itself was returned. Take for example:
It never occurred to me that obj and obj must be the same object,
especially since the example shows differently. I believe it is most
reasonable to expect to get back what the method returns. Were you
actually misled into believing that you always get back the original
receiver?
Kind regards
robert
···
On Sun, Jul 31, 2011 at 8:47 PM, 7stud -- <bbxx789_05ss@yahoo.com> wrote:
Chris White wrote in post #1014020:
On Jul 31, 2011, at 10:51 AM, 7stud -- wrote:
end
receiver, and k.class would therefore output: Klass.