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



196
197
198
# File 'lib/jruby/scala_support.rb', line 196

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

#-(o) ⇒ Object



200
201
202
# File 'lib/jruby/scala_support.rb', line 200

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

#eachObject



204
205
206
207
208
209
210
211
212
# File 'lib/jruby/scala_support.rb', line 204

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



214
215
216
217
218
219
220
# File 'lib/jruby/scala_support.rb', line 214

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