Ruby String Magic

Ruby strings are powerful. You could say Ruby is built around manipulating strings. There are tons of ways how to work with strings and as of Ruby 2.7.1 String offers 130 instance methods. Knowing them well can save you a lot of time.

What follows is a list of 10 lesser known things about strings: Some of them useful, some of them idiosyncratic, some both.

Named Format Strings

String Concatenation

Strings + Empty Ranges

Whitespace Matching

String#succ

Stdlib String Compression

Using Regex Groups in String#[]

Rexep.union

Convert a String from snake_case to CamelCase

Convert a String from CamelCase to snake_case

Resources

More Idiosyncratic Ruby