Chapter 1. Strings
Ruby is a programmer-friendly language. If you are already familiar with object oriented programming, Ruby should quickly become second nature. If you’ve struggled with learning object-oriented programming or are not familiar with it, Ruby should make more sense to you than other object-oriented languages because Ruby’s methods are consistently named, concise, and generally act the way you expect.
Throughout this book, we demonstrate concepts through interactive Ruby sessions. Strings are a good place to start because not only are they a useful data type, they’re easy to create and use. They provide a simple introduction to Ruby, a point of comparison between Ruby and other languages you might know, and an approachable way to introduce important Ruby concepts like duck typing (see Recipe 1.12), open classes (demonstrated in Recipe 1.10), symbols (Recipe 1.7), and even Ruby gems (Recipe 1.20).
If you use Mac OS X or a Unix environment with Ruby installed, go to
your command line right now and type irb. If you’re using Windows, you can download
and install the One-Click Installer from http://rubyforge.org/projects/rubyinstaller/, and do the
same from a command prompt (you can also run the fxri program, if that’s more comfortable for
you). You’ve now entered an interactive Ruby shell, and you can follow
along with the code samples in most of this book’s recipes.
Strings in Ruby are much like strings in other dynamic languages like Perl, Python and PHP. They’re not ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access