PH = Pete Hodgson SK = Siep Korteling PH> Given a sorted enumeration I need to find the first gap in a sequence. PH> e.g. PH> 3 == find_gap [1,2,4,5] PH> nil == find_gap [1,2,3,4] SK> The following does not quite meet your specs (it returns an array with SK> all gaps, empty if there are no gaps). Anyway, here is my try: > > def find_gaps( ar ) > (ar.first .. ar.last).to_a - ar > end Given the above definition, it's easy to get Pete's behavior exactly: def find_gap( ar ) find_gaps(ar).first end And then you have a choice of methods to use, depending on whether you need the full list or just the first gap.