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


#1

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")

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

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


#2

Read the description of String#delete :

http://ruby-doc.org/core-1.9.3/String.html#method-i-delete

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


#3

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