From: Mathieu Bouchard Date: 2002-02-07T01:47:08+09:00 Subject: Re: Array#splice method On Tue, 29 Jan 2002, michael libby wrote: > Thanks (to everyone) for the great answers. Once again Ruby excels at this > stuff (so far every example in the book turns out to be easier in Ruby > than in Perl-- I hope this is a trend {grin}). > > (on Mon, 28 Jan 2002 14:16:57 +0900) Mathieu Bouchard > wrote: > > class Array > > def splice(i,n,v) > > r = slice!(i,n); self[i,0]=v; r > > end > > end > I did have to modify this to: Okay, so my 2nd proposal was buggy. The former, iirc, was better. by the way, for it to look more like Perl's splice, the method signature should be (i,n,*v) instead of (i,n,v)... because Perl's splice has variable number of args. ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju