I'm trying to do a binary search on a list of 1 million employee IDs, already sorted out.
def exist?(id) lower = -1 upper = $employee_list.count while true mid = (lower + upper) / 2 if upper == lower + 1 return nil if id == $employee_list[mid] return mid if id < $employee_list[mid] upper = mid else lower = mid end end end end end
I get the error:
NoMethodError:undefined method 'call' for nil:NilClass
Also, I'm trying to make it such that if
exist?(54) is in the list, it will return