Class: Array
Instance Method Summary collapse
Instance Method Details
#merge ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/bolo/core_ext/array.rb', line 2 def merge case first when Array to_h when Hash inject(:merge) else Hash[*self] end end |
#uniq? ⇒ Boolean
21 22 23 |
# File 'lib/bolo/core_ext/array.rb', line 21 def uniq? (count - uniq.count).zero? end |
#uniqs ⇒ Object
13 14 15 |
# File 'lib/bolo/core_ext/array.rb', line 13 def uniqs group_by{|i| i }.select{|_, v| v.one? }.keys end |
#ununiqs ⇒ Object
17 18 19 |
# File 'lib/bolo/core_ext/array.rb', line 17 def ununiqs group_by{|i| i }.reject{|_, v| v.one? }.keys end |
#ziph(*arr) ⇒ Object
25 26 27 |
# File 'lib/bolo/core_ext/array.rb', line 25 def ziph(*arr) [self, arr].transpose.to_h end |