From the course: Complete Guide to Ruby
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Strings: Escaping and interpolation - Ruby Tutorial
From the course: Complete Guide to Ruby
Strings: Escaping and interpolation
- [Instructor] In this movie, we'll learn about string escaping and string interpolation. Strings can be defined with double quotes or single quotes. We call these delimiters because they delimit the start and the end of the string. But there are some considerations to keep in mind when choosing which delimiter to use. The first consideration is whether the string delimiter is also contained inside the string. For example, it's fine to have a single quote inside a string that's delimited by double quotes, but a single quote inside a string that's delimited by single quotes is a problem. Ruby sees the first single quote and recognizes that it's the start of the string, and then when it encounters the second single quote, it thinks the string is done. Everything after is not included in the string and will probably create an error in the code. You would need to use a backslash in front of that second quote to escape it. Ruby now sees it as a simple single quote character inside the…
Contents
-
-
-
-
(Locked)
Objects2m 30s
-
Variables3m 26s
-
(Locked)
Numbers: Integers3m 46s
-
(Locked)
Numbers: Floats4m 4s
-
(Locked)
Strings5m 34s
-
(Locked)
Strings: Escaping and interpolation5m 36s
-
(Locked)
Arrays5m 35s
-
Array methods6m 59s
-
(Locked)
Hashes5m 2s
-
(Locked)
Symbols5m 41s
-
(Locked)
Booleans5m 29s
-
(Locked)
Ranges5m 16s
-
(Locked)
Constants2m 53s
-
(Locked)
Nil2m 57s
-
(Locked)
Challenge: Roman numerals1m 2s
-
(Locked)
Solution: Roman numerals1m 19s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-