Setting Up the 'If' Branch, Part 2 My .gsub! method doesn't work!


<In what way does your code behave incorrectly? Include ALL error messages.>
The .gsub! method doesn’t work yet I put user’s input please string this means war at the terminal clicked enter and nothing happened ???
BUT strangely the exercice is considered as succeed ??? Green next button && green instructions

print "Could you give some 
input ? "
if user_input.include? "s"
   user_input.gsub!(/s/, "th")

thanks for your help !


gsub is working is fine, but everything is happening under the hood.

the substitution is working fine, but you need use puts to display the new string if you want.


Oh yes ! It works when you add puts user_input .
I thought gets.chomp would be enough ???
Thanks a lot Stetim94 ! :smiley:


no, gets.chomp is only prompting the user for input, to display output we need to use puts (or print)


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