Chapter 3. Strings and Ranges
I’ve made use of strings in many of my programs so far. In fact, a string was featured in the very first program in the book. Here it is again:
puts 'hello world'
Although that first program used a string enclosed within single quotes, my second program used a string in double quotes:
print('Enter your name: ' ) name = gets() puts( "Hello #{name}" )
Double-quoted strings do more work than single-quoted strings. In particular, they have the ability to evaluate bits of themselves as though they were programming code. To have something evaluated, you need to place it between a pair of curly brackets preceded by a hash mark ...
Get The Book of Ruby 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.