Module: Java::java::lang::Iterable

Includes:
Enumerable
Defined in:
core/src/main/ruby/jruby/java/java_ext/java.lang.rb

Overview

A `java.lang.Iterable` will act like a Ruby `Enumerable`.

See Also:

Instance Method Summary (collapse)

Instance Method Details

- (Integer) count(obj = nil, &block)

Re-defined `Enumerable#count`.

Returns:

  • (Integer)

    matched elements count

Since:

  • 9.1.3



80
81
82
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 80

def count(obj = nil, &block)
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
end

- (Java::java::util::Iterable, Enumerator) each(&block)

Ruby style `Enumerable#each` iteration for Java iterable types.

Returns:

  • (Java::java::util::Iterable)

    self (since 9.1.3)

  • (Enumerator)

    if called without a block to yield to



50
51
52
53
54
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 50

def each(&block)
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
  # iter = iterator
  # yield(iter.next) while iter.hasNext
end

- (Java::java::util::Iterable, Enumerator) each_with_index(&block)

Ruby style `Enumerable#each_with_index` for Java iterable types.

Returns:

  • (Java::java::util::Iterable)

    self (since 9.1.3)

  • (Enumerator)

    if called without a block to yield to



59
60
61
62
63
64
65
66
67
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 59

def each_with_index(&block)
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
  # index = 0
  # iter = iterator
  # while iter.hasNext
  #   yield(iter.next, index)
  #   index += 1
  # end
end

- (Array) to_a Also known as: entries

Re-defined `Enumerable#to_a`.

Returns:

  • (Array)

Since:

  • 9.1.3



72
73
74
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 72

def to_a
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
end