Answer the question
In order to leave comments, you need to log in
How to select unique ones from a hash by parameter in RUBY?
Let's say we have a hash:
list = {[name: 'one', type: 'number'],[name: 'one', type: 'string'],[name: 'two', type: 'number']}
list = {[name: 'one', type: 'number'],[name: 'two', type: 'number']}
Answer the question
In order to leave comments, you need to log in
list = [{name: 'one', type: 'number'}, {name: 'one', type: 'string'}, {name: 'two', type: 'number'}]
list.uniq {|i| i[:name] }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question