Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice Strings in Ruby!
You have completed Practice Strings in Ruby!
Preview
Now that you've coded your solution to the practice problem, I'll show you how I did it.
One Solution
Here's my code:
puts 'When you include \t in a double-quoted string in Ruby, it looks like this:'
puts "before\tafter"
puts 'When you include \n in a double-quoted string, it looks like this:'
puts "before\nafter"
Additional Links
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Here's my solution, it's okay if
yours is slightly different, but
0:00
if you see something interesting in my
code you should consider borrowing it to
0:00
improve your own program.
0:03
So for each line where I need to show what
an escape sequence looks like in code,
0:07
it's a bit of a pain to
have to escape the \.
0:11
So what I did was, I put those
lines in single quoted strings.
0:14
That way when I put /t, it puts that
literal value, /t, into the output.
0:19
Then, for lines where I need to show what
the escape sequence actually looks like
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up