15. String and string methods (Intro)


Declare a variable name and set it equal to a string containing your name. Call .downcase on your name to make it all lower case, call .reverse on your lowercase name to make it backwards, then call .upcase on your backwards name to make it ALL CAPS.

In Ruby, you can do this two ways: each method call on a separate line, or you can chain them together, like this:


So the 2nd way is:

name = “Mr.poopybutthole”.downcase.reverse.upcase

My question is how does the first method look like in code?

Is it like this?(if it is, makes little sense to copy paste it so much)

name = “Mr.poopybutthole”.downcase
name = “Mr.poopybutthole”.downcase.reverse
name = “Mr.poopybutthole”.downcase.reverse.upcase


IMHO, the wording of the exercise is bit unclear. I think, it can be interpreted in two ways:


name =
“Mr Potty Mouth”


name = "Mr Potty Mouth"
name = name.downcase
name = name.reverse
name = name.upcase

To be honest, I don’t see the point in both solutions…


Yeah, the second one looks like what they meant.
The first one looks like a verticle version of name = “Mr.poopybutthole”.downcase.reverse.upcase.

Thank you for your reply :slight_smile: !


Chaining lots of calls together can be a recipe for disaster. We never know when we could get an unintended side effect (one of the functions returning a value we didn’t expect) and it would be hard to figure out where the problem arose.
By doing one call at a time we can identify trouble easier


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