To insert a character at a specific index in a string in Ruby, you can use string interpolation or the `insert()` method.
In this example,
str
with a value of "Hello World"
.'!'
at index 5
.str
.str = 'Hello World'
str.insert(5, '!')
puts str
Hello! World
In this tutorial, we learned How to Insert Character at Specific Index in String in Ruby language with well detailed examples.