Module: Ruborithms::Algorithms::LinearSearch::ClassMethods

Defined in:
lib/ruborithms/algorithms/linear_search.rb

Instance Method Summary collapse

Instance Method Details

#linear_search(object, value) ⇒ Object



11
12
13
14
15
# File 'lib/ruborithms/algorithms/linear_search.rb', line 11

def linear_search(object, value)
  0.upto(object.count - 1) do |i|
    return i if value == object[i]
  end; nil
end