Home > Articles > Programming > Ruby

  • Print
  • + Share This
This chapter is from the book

2.40 Conclusion

In this chapter, we have seen the basics of representing strings (both single-quoted strings and double-quoted strings). We’ve seen how to interpolate expressions into double-quoted strings, and how the double quotes also allow certain special characters to be inserted with escape sequences. We’ve seen the %q and %Q forms, which permit us to choose our own delimiters for convenience. Finally, we’ve seen the here-document syntax, carried over from older contexts such as UNIX shells.

This chapter has demonstrated all the important operations a programmer wants to perform on a string, including concatenation, searching, extracting substrings, tokenizing, and much more. We have seen how to iterate over a string by line or by byte. We have seen how to transform a string to and from a coded form such as Base64 or compressed form.

It’s time now to move on to a related topic—regular expressions. Regular expressions are a powerful tool for detecting patterns in strings. We’ll cover this topic in the next chapter.

  • + Share This
  • 🔖 Save To Your Account