FAQ: Introduction to Ruby - Strings and String Methods

This community-built FAQ covers the “Strings and String Methods” exercise from the lesson “Introduction to Ruby”.

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

Learn Ruby

FAQs on the exercise Strings and String Methods

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!

How do you chain methods on one line. I do not understand this example:

1 Like

name = “Jason”

puts name.downcase.reverse.upcase

it will only show you the last command. which in this case is upcase letters


I tried linking the three methods but was confused that you then only get back out the third method. What kind of application would you have for this?

check the spellings of methods in your code.

I had the exact same experience as these other folks. It’s not my spelling that’s the issue.

1 Like

The chain method works with just one line too.

puts name = “Frank”.downcase.reverse.upcase

worked just fine.

1 Like

When using the chain method, I got back all methods at once (except ‘downcase’ and ‘upcase’, they naturally nullify the other. In this case, since I wrote upcase last, it’s the one working by the end).

name = “Alana”
puts name.downcase.reverse.upcase

I got my name spelled backwards and on lowercase:


1 Like

@theboyjenkins is this perhaps what has happened to you? Or do you only get back out the third method indeed?

How do you return a string?

I also have this question. I understand that the result will only spit out the last method in the chain… but am wondering why that would be useful in an application? Maybe changing someone’s name from lower case to reverse to upper case isn’t necessarily a good real world example.

I don’t think this is a good exercise because the result is not what the user expects.
The explanation that these methods (upcase, downcase, reverse) are not in-place is missing.
To explain what in-place means look at this example:
name = “Aaron”
puts name

Output: Aaron

name = name.reverse
puts name

Output: noraA

So like you see the methods do not change String itself but they return a value.
If you want to see the result either have to

  • Use puts in the same line like so: puts “Aaron”.reverse
  • Store the result in a variable: name = “Aaron”.reverse
  • And after that: puts name

I found that when I used this method it worked for me. FYI complete noob here so any critique is welcome and useful.

name_variaton = name.upcase, name.downcase, name.reverse
name= “Jon”
puts name_variation

1 Like