Module: Java::JavaUtil::Collection

Defined in:
lib/caruby/import/java.rb

Overview

Aliases Java Collection methods with the standard Ruby Set counterpart, e.g. delete for remove.

Instance Method Summary collapse

Instance Method Details

#delete(item) ⇒ Object

Removes the given item from this collection.



76
77
78
79
# File 'lib/caruby/import/java.rb', line 76

def delete(item)
  # can't alias delete to remove, since a Java interface doesn't implement any methods
  remove(item)
end

#delete_ifObject

Removes the items from this collection for which the block given to this method returns a non-nil, non-false value.



82
83
84
85
# File 'lib/caruby/import/java.rb', line 82

def delete_if
  removeAll(select { |item| yield item })
  self
end

#to_aObject



71
72
73
# File 'lib/caruby/import/java.rb', line 71

def to_a
  inject(Array.new) { |array, item| array << item }
end