Ruby - Create an array of single-quoted strings without typing all the quotation marks

Introduction

To create an array of single-quoted strings without typing all the quotation marks, put unquoted text separated by spaces between parentheses preceded by %w.

Use a capital %W for double-quoted strings.

Demo

y = %w( this is an array of strings ) 
puts y

Result

Related Topic