From: Yossef Mendelssohn Date: 2008-08-15T02:42:14+09:00 Subject: Re: Idiom of removing a particular character from a String? On Aug 14, 9:21 am, "Lorenzo E. Danielsson" wrote: > Hi all, > > Is there any particular idiom for removing a particular character from a > string *by index* and returning the resulting string? The following > makes my old eyes sore: > > rem = str.clone > rem[i] = "" > rem > > as does this: > > rem = str.scan(/./) > rem.delete_at(i) > rem.to_s > > It seems there should be some more idiomatic way to do this, something > like str.annihilate_char_at_index_possibly_without_a_bang(i), read as > String#delete_at(i) and String#delete_at!(i). Of course these methods > don't exist, and "".methods doesn't turn up anything interesting. So > what is a *decent* way of performing this? > > Lorenzo Lorenzo, It seems reading comprehension isn't a strong suit for ruby-talk today. As far as I know, there is no such method. You're probably stuck with reopening String and adding it yourself. -- -yossef