Forgive me if this has already been asked, I could not find it.
I have an array of objects, for example:
[<#Folder id:1, name:'Foo', display_order: 1>, <#Folder id:1, name:'Bar', display_order: 2>, <#Folder id:1, name:'Baz', display_order: 3>]
I would like to convert this array to an array of only names, for example:
['Foo','Bar','Baz']
and although I am in this, it would be nice if I could use the same technique in the future to create an array of two parameters, that is, the name and display order would look like this:
[['Foo',1],['Bar',2],['Baz',3]]
What is the best "Ruby Way" for this?
Thanks!
source share