Module: JRuby::ScalaSupport::Seq::Common
Instance Method Summary collapse
Instance Method Details
#[](index) ⇒ Object
235 236 237 238 239 240 241 242 243 |
# File 'lib/jruby/scala_support.rb', line 235 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
245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/jruby/scala_support.rb', line 245 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
259 260 261 262 263 264 265 |
# File 'lib/jruby/scala_support.rb', line 259 def to_s first = true each_with_object("[") do |item, str| first ? first = false : str << ", " str << item.to_s end << "]" end |