Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Foundations Strings String Methods: Part 1

The .chomp method doesn't seem to be removing whitespace from the beginning

In the String Methods: Part 1, Jason goes over both the .chomp and the .chop methods.

He tells us that the .chomp method is supposed to remove whitespace from both the beginning and end of a string.

When I run this in my Ruby Console, it seems to be only removing whitespace at the end of a string (equivalent to the function of .chop)

Could someone clarify the two?

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Yeah, he says it, but documentation seems to differ. And chop has a different function than what you described.

http://ruby-doc.org/core-2.0/String.html#method-i-chomp