+ 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.
2 Respostas
+ 2
"this is a string".split("");
The above code should generate an array consisting of each character in the string!
+ 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.