Delete Word in a String... What is wrong here


Q. Write the code to delete the word “Ruby” from the following string:
str = “Ruby is a great way to spend the afternoon”
--------------------------------------My Solution------------------------

# Just modify the string. You don't need any output.
str = "Ruby is a great way to spend the afternoon"
puts str.delete("Ruby")

Incorrect Response
No. Recall our discussion on deleting characters using string indexing and the empty string.

-----------------------Please advice correct Answer----------------------------


Read the description of String#delete :

As you can see, the method does not do what you think it does.


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