L
Lorenzo E. Danielsson
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 = ""
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
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 = ""
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