Lets say I have:
a = "Stack Overflow"
Is there a function where I can do something like:
> a.replace!(3, 10, " hello ")
> a
=> "Sta hello flow"
or so开发者_开发百科mething similar?
basically, said function I don't know of would remove all text inbetween the specified indexes, then insert the given text after the start index.
Try this:
a = "Stack Overflow"
a[3..9] = " hello "
a
Untested code:
a[3,10] = "hello" ?
精彩评论