Say I want to create an array with ["one", "two", nil], is it possible to do so using shorthand %w[] syntax? Obviously this does not work:
array = %w[one two nil]
=> ["one", "two", "nil"]
array[2].nil?
=> false
Ruby 1.9.3
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. The whole purpose of that convenience syntax is to avoid putting quotes around string literals, and the separator comma.