From: Keith Bennett Date: 2011-08-01T03:48:23+09:00 Subject: Re: send() docs are wrong --Apple-Mail-12-970885931 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 My two cents...I think something like this would be preferable: obj1.send(symbol [, args...]) =E2=86=92 obj2 ...or even better... obj.send(instance_method_name_as_symbol [, args...]) =E2=86=92 = instance_method_return_value I agree that use of 'obj' for both is ambiguous, and think it's = important for documentation to be more precise than that. - Keith --- Keith R. Bennett Senior Software Consultant Business: http://www.bbsinc.biz Linked In: http://www.linkedin.com/in/keithrbennett Blogs: http://krbtech.wordpress.com, http://keithrbennett.wordpress.com On Jul 31, 2011, at 2:00 PM, Chris White wrote: >=20 > On Jul 31, 2011, at 10:51 AM, 7stud -- wrote: >=20 >> obj.send(symbol [, args...]) =E2=86=92 obj >> obj.__send__(symbol [, args...]) =E2=86=92 obj >>=20 >> 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: >>=20 >> class Klass >> def hello(*args) >> "Hello " + args.join(' ') >> end >> end >>=20 >> k =3D Klass.new >> x =3D k.send :hello, "gentle", "readers" >>=20 >> puts x.class >>=20 >> --output:-- >> String >>=20 >> According to the docs, the return value of send() should be k, the >> receiver, and k.class would therefore output: Klass. >=20 > 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=20 >=20 > obj.send(symbol [, args...]) =E2=86=92 otherobj >=20 > Which would work for your case, but not if the object itself was = returned. Take for example: >=20 > class Klass > def test > self > end > end >=20 > k =3D Klass.new > puts (k.send :test).class >=20 > --output:-- > Klass >=20 > Regards, > Chris White > Twitter: http://www.twitter.com/cwgem --Apple-Mail-12-970885931--