Setting Up The "If" Branch Part"2



Setting up the "If" Branch Part 2 won't work the code for a reason of a coma "," in between of "(/s/**,** "th")". Throws an error again and again because of the coma which I assume supposed to be there.

print "Smooth"
user_input = gets.chomp.downcase!
    user_input.include? "s" then
    user_input.gsub! (/s/, "th")
    print "Word including letter S!"
    print user_input
    print "Word including S!"
    print user_input

Any thoughts?


If you're referring to the syntax error that code would trigger, then keep in mind that ruby has no idea what you mean and can only point at where the code stops being valid syntax. Your mistake may be earlier than where it points.


I figured, it has been the space just before the bracket as it was not supposed to be there.

"user_input.gsub!(/s/, "th")"

Thank you!


Because an alternative syntax for calling methods in ruby is to omit the parentheses and instead leave a space after the function name, followed by the argument list

> (1, 2)
SyntaxError: (irb):1: syntax error, unexpected ',', expecting ')'
(1, 2)


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