jeudi 15 novembre 2018

ruby - help need to convert an array to a specific type of array of arrays, duplicating the keys as [key, value] int he list

I want to convert and array into a specific type of array of arrays.

array = ["Project", "Publication"]

into

array_of_arrays =[["Project", "Project"], ["Publication", "Publication"] ]

The array is not just limited to size two. Its a growing list , so looking for some function to convert it to array_of_arrays.

Appreciate any help.

Aucun commentaire:

Enregistrer un commentaire