Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/milkode/common/array_diff.rb,
lib/milkode/cdweb/app.rb

Overview

Author:

  • ongaeshi

Instance Method Summary collapse

Instance Method Details

#diff(other) ⇒ Object



9
10
11
12
13
14
# File 'lib/milkode/common/array_diff.rb', line 9

def diff(other)
  self_diff = self.reject {|i| other.include? i}
  other_diff = other.reject {|j| self.include? j}
  
  return [self_diff, other_diff]
end

#map_with_index(&block) ⇒ Object



451
452
453
# File 'lib/milkode/cdweb/app.rb', line 451

def map_with_index(&block)
  dup.map_with_index!(&block)
end

#map_with_index!Object



447
448
449
# File 'lib/milkode/cdweb/app.rb', line 447

def map_with_index!
  each_with_index do |e, idx| self[idx] = yield(e, idx); end
end