Given a sorted enumeration I need to find the first gap in a sequence.
3 == find_gap [1,2,4,5]
nil == find_gap [1,2,3,4]
Here’s the best I can come up with
def first_gap( seq )
seq.each_cons(2) do |l,r|
_next = l.next
return _next if r!= _next
but it seems rather ugly. Anyone have a more elegant implementation?