From: Gavin Sinclair Date: 2004-05-12T09:00:01+09:00 Subject: Re: Proposal: Object#send(nil) -> self On Wednesday, May 12, 2004, 8:23:52 AM, David wrote: > Hi -- > Gavin Sinclair writes: >> A quick one. I see some sense in Object#send accepting 'nil' as the >> message. You send no message, you get the plain object. Does anyone >> agree? >> >> #send is clearly useful when you want to vary the message sent to an >> object based on some condition. Sometimes the default condition is to >> send no message, but that can't be coded as elegantly. >> >> For example: >> >> date_colour_msg = >> case Date.today - date >> when 0 then :red >> when 1 then :yellow >> when 2..5 then :green >> else >> nil # Default: whatever the normal colour is. >> end >> >> date_str = date.to_s.send(date_colour_msg) > I don't like the special-case nature of this. I believe send should > send, not intercept (which is what this comes down to), its message. I (generally) don't like special cases either, but this doesn't strike me as such. The way 'date_str.send(nil)' reads to me is literally "send no message to date_str". I really like the message-passing paradigm, but sometimes ... you've just gotta *not* pass a message :) Gavin