ruby - Split string and append to array -


i split string , append split result 2 separate arrays simultaneously. there way this? example:

mystrings = ['abc:def', 'ghi:jkl', 'mno:pqr'] first = [] second = [] mystrings.each |string|   first, second << string.split(':') end 

this doesn't work. didn't know if there syntactical ruby way perform split , appending simultaneously.

mystrings = ['abc:def', 'ghi:jkl', 'mno:pqr'] first, second = mystrings.map{|str| str.split(":")}.transpose 

Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -