Learn Ruby the Hard Way – Exercise 10 What was That?

Here is my work for Exercise 10.

Exercise 10 code
Exercise 10 code
Exercise 10 output
Exercise 10 output

Study Drills:
1. Memorize all the escape sequences by putting them on flash cards.

Here is my flashcard set for Ruby Escape Sequences. Feel free to use it!

2. Use ''' (triple-single-quote) instead. Can you see why you might use that instead of """?
You can enclose strings with single quotes ” or double quotes “”. String interpolation can only be done within double quotes. When you change the triple-double-quotes in the example to triple-single-quotes, you will get an error because there is a single quote for “I’ll”. Ruby then reads that single quote as the end of the code line. You can use triple-single-quotes if you are enclosing strings without any escape sequences or string interpolation.Otherwise, use triple-double-quotes for multi-line strings.

3. Combine escape sequences and format strings to create a more complex format.

String interpolation and escape sequences
String interpolation and escape sequences
Output with tabs, new lines, double quotes...
Output with tabs, new lines, double quotes…
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s