From: Markus Echterhoff Date: 2007-08-12T21:00:11+09:00 Subject: Re: Bug or bad documentation for Array.insert() On Thursday 09 August 2007 19:55:23 Daniel Berger wrote: > Nope, the docs show that the second argument is optional. As it stands > now there are a few methods like this scattered throughout Ruby where > you can end up with what amounts to a no-op in certain situations, > e.g. File.join with no arguments. > > Not that I necessarily agree with the current semantics, but it is > documented properly. It does require that you understand "obj..." to > mean "0 or more". > > Regards, > > Dan Thanks, when I read the "obj..." as you say it's clear. On Thursday 09 August 2007 21:15:43 Florian Frank wrote: > I think the semantics are just fine. Consider this case: > > b = [] # maybe a result from some other method > a.insert 23, *b > > I wouldn't want an exception thrown here. It would make it necessary to > check for b's emptiness before every call to Array#insert. If people > forget the check, it might cause an error when the impossible occurs > anyway. I think this is also true. I like errors thrown on everything I didn't expect. I just hope this is a constant behavior and not changing from method to method, so that I can expect it and relax without argument checking.