There is not , but you can create it either in a clean way:
a = [0,2,1,0,3] module Enumerable def first_not(&block) find{ |x| !block[x] } end end p a.first_not(&:zero?)
... or an awfully fun way of hacking:
class Proc def ! proc{ |o,*a| !self[o,*a] } end end p a.find(&!(:zero?.to_proc))
... or a complicated but terribly dangerous way:
class Symbol def ! proc{ |o,*a| !o.send(self,*a) } end end p a.find(&!:zero?)
But I would advocate just skipping the complicated use of Symbol#to_proc and saying what you want:
p a.find{ |i| !i.zero? }
source share