Module: Enumerable

Defined in:
lib/ext/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#euclidean_distance(other) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/ext/enumerable.rb', line 2

def euclidean_distance(other)
  sum = 0.0
  self.each_index do |i|
    sum += (self[i] - other[i])**2
  end
  Math.sqrt(sum)
end