ruby split string at index code example
Example 1: split ruby
# no number splits on single whitespace
myArray = "hello hello".split
# / / is one white space
# limit value is 2
myArray = "hello hello".split(/ /, 2)
# -1 means no limit to the number of fields returned,
myArray = "hello hello".split('o', -1)
Example 2: how to split string into characters ruby
string = "hey there"
string.chars #=> ["h", "e", "y", " ", "t", "h", "e", "r", "e"]
#OR
string.split("")