8.1. Working with strings
Ruby provides two built-in classes that, between them, provide all the functionality of text representation and manipulation: the String class and the Symbol class. Strings and symbols are deeply different from each other, but they’re similar enough in their shared capacity to represent text that they merit being discussed in the same chapter. We’ll start with strings, which are the standard way to represent bodies of text of arbitrary content and length. You’ve seen strings in many contexts already; here, we’ll get more deeply into some of their semantics and abilities. We’ll look first at how you write strings, after which we’ll discuss a number of ways in which you can manipulate strings, query them (for example, ...
Get The Well-Grounded Rubyist, Second Edition 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.