Module: JRuby::ScalaSupport::Seq::Common
Instance Method Summary collapse
Instance Method Details
#[](index) ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'lib/jruby/scala_support.rb', line 131 def [](index) if index < 0 @raw.apply(size + index).from_scala elsif index >= size nil else @raw.apply(index).from_scala end end |
#each ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/jruby/scala_support.rb', line 141 def each if block_given? @raw.foreach do |item| yield item.from_scala end else iterator = @raw.iterator Enumerator.new do |yielder| yielder << iterator.next.from_scala while iterator.hasNext end end end |
#to_s ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/jruby/scala_support.rb', line 155 def to_s first = true each_with_object("[") do |item, str| first ? first = false : str << ", " str << item.to_s end << "]" end |