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 () 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 () below!
Agree with a comment or answer? Like () to up-vote the contribution!
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).
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”
name.reverse
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
or
Store the result in a variable: name = “Aaron”.reverse