Chapter 1 - More With Less
Exercise 1: Reverse-o-Matic
The goal for your first exercise is to write a script that reverses text. Here’s what it should do:
- Prompt the user to type a phrase and press Enter.
- Use the
getsmethod to read the string the user entered.
chompon the user’s string to remove the newline character from the end.
reverseon the string, and display the result.
When you’re ready, have a look at the solution.
Exercise 2: IRB Session
irb from your terminal, and try the following expressions:
After you try them out, you can see an explanation of the results.