Insert Word into String.. what is wrong

Insert the word “easy” into the end of the string "Ruby makes automation ". Hint: it
might be useful to utilize negative indexing here

—my Solution -----------------------

str = "Ruby makes automation "
puts str.insert(-1,“easy”)

Incorrect Response
Almost; remember that to insert text into a string, you can set the length portion of the index to 0

------please advice correct Answer---------

Works for me:

 >> str = "Ruby makes automation "
 => "Ruby makes automation "
 >> str.insert(-1,"easy")
 => "Ruby makes automation easy"

However, I would have used the more idiomatic (and easier to understand)

 str += "easy"


“Ruby makes automation” << “easy”

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.