From: Dave Howell Date: 2006-02-06T09:09:44+09:00 Subject: Re: Quiz #65, Principle of Great Surprise, and Array.delete sledgehammer On Feb 5, 2006, at 8:50, ara.t.howard@noaa.gov wrote: > On Sun, 5 Feb 2006, [ISO-8859-1] Simon Kr�ger wrote: > >> ara.t.howard@noaa.gov wrote: >> >>> [...] >>> not raising an error when the element is not found is an >>> amazingly bad idea that would mask many bugs >>> [...] >> > > in general i think methods basically fail into two categories > > - those that always succeed, Array#clear for example. these can > simply > return self. > > - those that might fail and need to either return nil or raise an > exception > to indicate this. raising is nice because you can chain. > > it's not clear to me why 'delete_first' would be in the first category > but i > think this is largely religious. I think you're confusing "failure" with something else. If I ask a method to delete a "22" from an array that contains none of them, then, as I see it, deleting nothing from the array is a correct, successful response. If I *care* if there are any such elements in the array in the first place I can easily (and succinctly) if myArray.index(element)