From: Adam Sanderson Date: 2006-10-04T00:45:13+09:00 Subject: Re: redefining splat? I would agree with Matt, if you are trying to redefine the splat operator (is that really what we're calling it? neat), with the .to_a or .to_ary to return a class instead of an array, you should make sure that the class looks enough like an array that it wouldn't break someone's expectations later. It might not make a big difference now, but should someone need to touch your code later, even if that person is yourself, you will save many headaches by not being overly trixy. .adam Matt Todd wrote: > > Can you redefine the * prefix operator? > > Why do you need to? I know slight modifications to do some cool > wizardry can be adventageous, but to me, what it seems like you want > is a completely different thing that will completely redefine the *. > (Even if only locally.) > > > I'm in the middle of refactoring some code. I have a function that > > looks like this > > > > def send_command cmd_arry > > type = cmd_arry.shift > > @comms.send(type, *cmd_arry) > > end > > What's wrong with... > > def send_command cmd_ary > cmd = Command.new(cmd_ary) > @comms.send(cmd.type, cmd.params) > end > > Or even... > > def send_command cmd_ary > cmd = Command.new(cmd_ary) > @comms.send cmd > end > > with #send overwritten to do something special with the Command class? > (Still retaining the original functionality otherwise.) > > Just my opinion. > > M.T.