+ 1

strings into arrays

I want to take inputted text and convert that string into an array of its characters. I am unsure of how to do this. A relative of mine claimed that strings are already arrays of characters but he doesn't use Ruby, he uses something called Euphoria so I am thinking there might be a difference.

28th Jul 2017, 1:34 PM
Sean Hinz
Sean Hinz - avatar
2 odpowiedzi
+ 2
"this is a string".split(""); The above code should generate an array consisting of each character in the string!
28th Jul 2017, 1:41 PM
Saka Oluwadamilola
Saka Oluwadamilola - avatar
+ 7
Indeed, strings can be manipulated like arrays. Consider: var = "test" puts var puts var[1] However, I've also heard that lists and arrays are different objects than strings, in Ruby.
28th Jul 2017, 1:43 PM
Hatsy Rei
Hatsy Rei - avatar