I’m trying out an exercise.
I want to be able to take in a list of input from user input and store
them in an array. the list would be separated by comma or space. then
output them in a list like this:
face
sound
city
note
How do I do this?
I’m trying out an exercise.
I want to be able to take in a list of input from user input and store
them in an array. the list would be separated by comma or space. then
output them in a list like this:
face
sound
city
note
How do I do this?
print "Enter stuff: "
input_arr = gets.chomp.split
p input_arr
puts input_arr
–output:–
$ ruby my_prog.rb
Enter stuff: face sound city note
[“face”, “sound”, “city”, “note”]
face
sound
city
note
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs