String array

I would like to know how I can put a word into an array character by
character, for example the user type the word “hello” and the array
would be [“h”,“e”,“l”,“l”,“o”], I only know how to this with gets but I
don’t want to press enter after every character.

thanks in advance

Oziris Moreira wrote:

I would like to know how I can put a word into an array character by
character, for example the user type the word “hello” and the array
would be [“h”,“e”,“l”,“l”,“o”], I only know how to this with gets but I
don’t want to press enter after every character.

thanks in advance

s = ‘hello’
s_array = s.split(’’)

Giampiero Z. wrote:

Oziris Moreira wrote:

I would like to know how I can put a word into an array character by
character, for example the user type the word “hello” and the array
would be [“h”,“e”,“l”,“l”,“o”], I only know how to this with gets but I
don’t want to press enter after every character.

thanks in advance

s = ‘hello’
s_array = s.split(’’)

thank you very much !

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs