Many thanks for all the helpful replies...the memoize and runtime/code-time uses make a good deal of sense to me. Calling private methods from outside an object seems a bit naughty but it's certainly a nicely illustrative example. -- Giles Bowkett http://www.gilesgoatboy.org On 5/19/06, Ross Bamford <rossrt / roscopeco.co.uk> wrote: > On Fri, 2006-05-19 at 16:43 +0900, Pit Capitain wrote: > > Giles Bowkett schrieb: > > > What's a good reason to use send() instead of a dot to send a message? > > > > > > Is it for situations where you know you're going to want to send an > > > object a message, but you don't know what that message is until > > > runtime? > > > > Giles, as others have noted, this is the main reason. Another one has > > been to call private methods of an object [...] > > Also, I've seen it used before to do things like: > > class C > define_method(:"wierd method with-illegal-chars") { puts "call me" } > end > > C.new.send(:"wierd method with-illegal-chars") > call me > > Can't remember exactly why, I think it was part of a memoize type thing, > to store stuff in methods without clashing or something. In any event it > seems like a bad idea to me, but there you go... > > -- > Ross Bamford - rosco / roscopeco.REMOVE.co.uk > > >