From: "Wayne E. Seguin" Date: 2007-10-12T21:09:15+09:00 Subject: Re: How to delete specific characters from a string? ------=_Part_11587_11443723.1192190955988 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/12/07, Giles Bowkett wrote: > > > This little problem is quite enjoyable: > > > > class String > > def delete_indices(*indices) > > indices.each do |index| > > self[index] = '' > > end > > self > > end > > end > > What's neat about that solution is that you can pass it a list or a range. > > >> "muppet".delete_indices(2,4) > => "mupe" > >> "muppet".delete_indices(2..4) > => "mut" > > -- > Giles Bowkett I love that observation, great point Giles! Truly enjoyable. ~Wayne ------=_Part_11587_11443723.1192190955988--