Strings in Ruby can be constructed with single or double quotes, but only double-quoted strings support interpolation, where the result of any Ruby expression can be embedded with the #{} syntax. This allows you to write puts "Hello, #{name}!" instead of concatenating pieces together. For printing output, the puts method writes a string followed by a newline, print omits the newline, and p outputs the inspected representation of an object, which is invaluable for debugging complex data structures.
Regular expressions are first-class objects in Ruby, written between forward slashes. The match method applies a pattern to a string and returns a MatchData object, while the =~ operator returns the index of the first match or nil if no match is found. The gsub method replaces every occurrence of a pattern with a given replacement string or with the result of a block, making it easy to transform text programmatically, such as masking vowels or capitalizing words.
Ruby offers several convenience operators for everyday programming. The ternary operator provides a compact one-line conditional of the form condition ? true_value : false_value. The splat operator gathers extra positional arguments into an array or, when used at a call site, expands an array into individual arguments; the double splat does the same for keyword arguments. The safe navigation operator invokes a method only when the receiver is not nil, returning nil otherwise, which prevents the dreaded NoMethodError on undefined nil receivers. For multi-branch conditions, case/when offers readable pattern matching that uses the case-equality operator, so it works naturally with ranges, classes, and regular expressions as well as literal values.