Basically what this question says. How can I delete a character at a given index position in a string? The String class does not seem to have methods for this.
If I have the string "HELLO", I want this output to be
["ELLO", "HLLO", "HELO", "HELO", "HELL"]
I use
d = Array.new(c.length){|i| c.slice(0, i)+c.slice(i+1, c.length)}
I donβt know if I use a slice! will work here because it will change the original line, right?
source share