FAQ: Thith Meanth War! - Downcase!

This community-built FAQ covers the “Downcase!” exercise from the lesson “Thith Meanth War!”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Ruby

FAQs on the exercise Downcase!

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

What are the uses of the exclamations and question marks after calling methods on strings while getting user input?

I have the same question!

By using an exclamation point after calling a method you modify the original object its called on. For example

original = "my string"
puts original.upcase      #puts "MY STRING"
puts original                    #puts "my string"
puts original.upcase!     #puts "MY STRING"
puts original                   #puts "MY STRING"

If we don’t use the exclamation mark the original method will not be changed. You can see that the “.upcase” does not change “original”. However, by using the exclamation mark we edit the original string/method as seen by the repeat of “MY STRING”.

The question mark acts as an if/else statement and tells the method to return a Boolean value (true or false).

num = [1.43, 2, 3.1, 4, 5, 6, 7.5, 8, 9.8, 10]
num.each  { |n|
  puts "#{n} >> #{n.is_a? Integer}"

The code above checks if each number in number in the “num” array is an integer (a whole number) and returns true if so. Try running it if you want to see what I mean.

I’m sorry it’s still not clear to me too with the purpose of the !
in your example

original = “my string”
puts original.upcase #puts “MY STRING”
puts original #puts “my string”
puts original.upcase! #puts “MY STRING”
puts original #puts “MY STRING”

Do you mean thanks to the .upcase! , the original will be now always in UPCASE and without the ! it will be basically a “one shot” change?

what does "Call the .downcase! method on user_input" mean. pls help

Hello, @ruby3535816482, and welcome to the Codecademy Forums!

You have a variable named user_input that will contain what the user enters in response to a prompt while the program is executed. We need to have all the letters that were entered be stored in lowercase. If any letters included in whatever was entered are in uppercase, we want them to be converted to lowercase, and the result saved in the variable user_input. In other words, the conversion should be performed in place.

Here’s how we do it: