How to preserve the user's original capitalization


I'm stuck on this additional challenge: Think about how you might preserve the user's original capitalization.

I can't yet reason through this one, using the code we've learned up until this point. And I really would like to stick with the code that's been taught so far, since I've noticed that some of the responses have been people recommending methods that haven't been reviewed yet.

Has anybody found a solution? Thanks a lot

print "Hello friend.  Give me some input.  Any input...  But make sure it contains an s, for pete'th thake..."
user_input = gets.chomp

if user_input.include? "s" || "c"
    user_input.gsub!(/s/, "th")
    user_input.gsub!(/c/, "th")

    puts "Daffy Duck says, #{user_input}!"

elsif user_input.include? ""
    print "I'm thtill waiting! :)"

    print "Hello friend!  I noticed your statement doesn't contain an 's'.  Put one in there pleathe..."


If you can't downcase the input, then instead of just having to replace s, you also have to replace S, am I missing something?

Also, note that the expression "s" || "c" is equivalent to "s"


I'm not quite sure what your first sentence means. Can you extrapolate?


How is "s" || "c" equivalent to "s"? Can you explain your reasoning here?


Test it in the console...

 > print "s" || "c"

This is a logical expression fundamental. It might be an idea to do some review.


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