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

sinatra

hi, possible modus operandi of this code in the sinatra : str.squish.downcase.tr(" ","_")

1 Answer

Adam Robertson
Adam Robertson
3,294 Points

It looks like it's attempting to underscorize the string. squish trims whitespace from the ends of the string, and replaces all multiple whitespace characters with a single one. downcase will make the string lowercase. tr will replace the character " " with the character "_". This isn't a great implementation of underscorizing, however, because it won't remove characters that aren't a-zA-Z, if that was the intention.