Locked lesson.
About this lesson
Modifying a string is simple with these string manipulation tips.
Exercise files
Download this lesson’s related exercise files.
String Manipulation - Solution.docx59 KB String Manipulation.docx
60.1 KB
Quick reference
String Manipulation
There are many ways to manipulate strings with Ruby.
When to use
Use these whenever you want to manipulate strings.
Instructions
Here are some built-in Ruby methods that let you manipulate strings:
.downcase - changes all letters to lowercase
.upcase - changes all letters to uppercase
.capitalize - capitalizes first letter
.reverse - reverses letters in a word
.swapcase - reverses the case of your words
.length - counts the number of characters in a string
Hints & tips
- Use a built-in Ruby method to manipulate strings!
Lesson notes are only available for subscribers.