Method: Enumerable#find

Defined in:
enum.c

#detect(ifnone = nil) {|obj| ... } ⇒ Object? #find(ifnone = nil) {|obj| ... } ⇒ Object?

Passes each entry in enum to block. Returns the first for which block is not false. If no object matches, calls ifnone and returns its result when it is specified, or returns nil

(1..10).detect  {|i| i % 5 == 0 and i % 7 == 0 }   #=> nil
(1..100).detect {|i| i % 5 == 0 and i % 7 == 0 }   #=> 35

Overloads:

  • #detect(ifnone = nil) {|obj| ... } ⇒ Object?

    Yields:

    • (obj)

    Returns:

  • #find(ifnone = nil) {|obj| ... } ⇒ Object?

    Yields:

    • (obj)

    Returns:



107
108
109
# File 'enum.c', line 107

static VALUE
enum_find(argc, argv, obj)
int argc;