Wali Chaudhary Wali Chaudhary - 5 months ago 31
Ruby Question

Ruby 2.3. How can I convert User input string into an array, and then split it into individual elements?

Ruby noob here. I've been on this for a couple of hours while, but I can't figure out how to store user input, turn it into an array, and then split the array into separate elements.

puts "Hey! What's up?"

response = Array.new
response << gets.chomp

crypt = response.each_slice(3).to_a
print crypt

This is what is outputted:

Hey! What's up?

This is what I want, but can't figure out:

[["N", "o", "t", "h", "i", "n"]]

I've looked at Ruby docs but got confused, so after several hours of trial and error I'm here. Thanks for the help!



puts "Hey! What's up?"

crypt = gets.chomp

p [crypt.split("")]