Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/robot_array.rb
Instance Method Summary collapse
-
#dupes? ⇒ Boolean
Returns true if this array has duplicates in it.
-
#dupes_by?(&block) ⇒ Boolean
Returns true if this array has duplicates in it, using the test passed in for uniqueness rather than the built in ruby test for equality.
Instance Method Details
#dupes? ⇒ Boolean
Returns true if this array has duplicates in it
["a", "b", "c", "a"].dupes?
# => true
7 8 9 |
# File 'lib/robot_array.rb', line 7 def dupes? self.uniq.length != self.length end |
#dupes_by?(&block) ⇒ Boolean
Returns true if this array has duplicates in it, using the test passed in for uniqueness rather than the built in ruby test for equality.
["a", "b", "c", "A"].dupes_by?(&:downcase)
# => true
18 19 20 |
# File 'lib/robot_array.rb', line 18 def dupes_by?(&block) self.uniq_by(&block).length != self.length end |