Module: JRuby::ScalaSupport::Set::Common

Includes:
Common
Included in:
Immutable, Mutable
Defined in:
lib/jruby/scala_support.rb

Instance Method Summary collapse

Instance Method Details

#+(o) ⇒ Object



300
301
302
# File 'lib/jruby/scala_support.rb', line 300

def +(o)
  (@raw + o).from_scala
end

#-(o) ⇒ Object



304
305
306
# File 'lib/jruby/scala_support.rb', line 304

def -(o)
  (@raw - o).from_scala
end

#eachObject



308
309
310
311
312
313
314
315
316
# File 'lib/jruby/scala_support.rb', line 308

def each
  if block_given?
    @raw.foreach { |item| yield item.from_scala }
  else
    Enumerator.new do |yielder|
      each { |item| yielder << item }
    end
  end
end

#to_sObject



318
319
320
321
322
323
324
# File 'lib/jruby/scala_support.rb', line 318

def to_s
  first = true
  each_with_object("#<Set: {") do |item, str|
    first ? first = false : str << ", "
    str << item.to_s
  end << "}>"
end