Chapter 2
Strings
Strings are probably the most important data structure for everyday computing. They’re used in practically every kind of program imaginable, and are also the raw material of the Web. As a result, strings make an excellent place to start our Ruby programming journey.
2.1 String Basics
Strings are made up of sequences of characters in a particular order. We’ve already seen several examples in the context of our “hello, world” programs in Chapter 1. Let’s see what happens if we type a string by itself (without puts
) into interactive Ruby:
A sequence of characters typed literally is called a string literal, which we’ve created here using the double quote character "
. The REPL prints ...
Get Learn Enough Ruby to Be Dangerous: Write Programs, Publish Gems, and Develop Sinatra Web Apps with Ruby now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.