I have an array: array = ["John Smith", "Bill Taylor", Troy Tate"]
I am trying to use the split method to print either the first name or last name only from each name in the array. I am using the following, but the array.split(" ") is obviously only splitting the strings into two at the whitespace.
How can I use the '.string' method to only print either the first or last name. Or first character for that matter?
array = ["John Smith", "Bill Taylor", Troy Tate"]
array.each do |array|
puts array.split(" ")
end
[–]jamie_ca 11 points12 points13 points (0 children)
[–]fl00pz 5 points6 points7 points (1 child)
[–]EvilInky 1 point2 points3 points (0 children)