stdlib/builtin/enumerable.rbs in rbs-0.14.0 vs stdlib/builtin/enumerable.rbs in rbs-0.15.0
- old
+ new
@@ -20,11 +20,11 @@
# %w[ant bear cat].all?(/t/) #=> false
# [1, 2i, 3.14].all?(Numeric) #=> true
# [nil, true, 99].all? #=> false
# [].all? #=> true
def all?: () -> bool
- | () { (Elem arg0) -> untyped } -> bool
+ | () { (Elem) -> boolish } -> bool
# Passes each element of the collection to the given block. The method
# returns `true` if the block ever returns a value other than `false` or
# `nil` . If the block is not given, Ruby adds an implicit block of `{
# |obj| obj }` that will cause
@@ -41,11 +41,11 @@
# [nil, true, 99].any?(Integer) #=> true
# [nil, true, 99].any? #=> true
# [].any? #=> false
# ```
def `any?`: () -> bool
- | () { (Elem arg0) -> untyped } -> bool
+ | () { (Elem) -> boolish } -> bool
def collect: [U] () { (Elem arg0) -> U } -> ::Array[U]
| () -> ::Enumerator[Elem, ::Array[untyped]]
def collect_concat: [U] () { (Elem arg0) -> ::Enumerator[U, untyped] } -> ::Array[U]
@@ -60,22 +60,22 @@
# ary.count #=> 4
# ary.count(2) #=> 2
# ary.count{ |x| x%2==0 } #=> 3
# ```
def count: () -> Integer
- | (?untyped arg0) -> Integer
- | () { (Elem arg0) -> untyped } -> Integer
+ | (?untyped) -> Integer
+ | () { (Elem) -> boolish } -> Integer
def cycle: (?Integer n) { (Elem arg0) -> untyped } -> NilClass
| (?Integer n) -> ::Enumerator[Elem, Return]
- def detect: (?Proc ifnone) { (Elem arg0) -> untyped } -> Elem?
+ def detect: (?Proc ifnone) { (Elem) -> boolish } -> Elem?
| (?Proc ifnone) -> ::Enumerator[Elem, Return]
def drop: (Integer n) -> ::Array[Elem]
- def drop_while: () { (Elem arg0) -> untyped } -> ::Array[Elem]
+ def drop_while: () { (Elem) -> boolish } -> ::Array[Elem]
| () -> ::Enumerator[Elem, Return]
def each_cons: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
| (Integer n) -> ::Enumerator[::Array[Elem], Return]
@@ -94,18 +94,18 @@
# require 'prime'
# Prime.entries 10 #=> [2, 3, 5, 7]
# ```
def entries: () -> ::Array[Elem]
- def find_all: () { (Elem arg0) -> untyped } -> ::Array[Elem]
+ def find_all: () { (Elem) -> boolish } -> ::Array[Elem]
| () -> ::Enumerator[Elem, Return]
alias select find_all
alias filter find_all
def find_index: (?untyped value) -> Integer?
- | () { (Elem arg0) -> untyped } -> Integer?
+ | () { (Elem) -> boolish } -> Integer?
| () -> ::Enumerator[Elem, Return]
# Returns the first element, or the first `n` elements, of the enumerable.
# If the enumerable is empty, the first form returns `nil`, and the
# second form returns an empty array.
@@ -226,11 +226,11 @@
# [nil].none? #=> true
# [nil, false].none? #=> true
# [nil, false, true].none? #=> false
# ```
def none?: () -> bool
- | () { (Elem arg0) -> untyped } -> bool
+ | () { (Elem) -> boolish } -> bool
# Passes each element of the collection to the given block. The method
# returns `true` if the block returns `true` exactly once. If the block is
# not given, `one?` will return `true` only if exactly one of the
# collection members is true.
@@ -247,16 +247,16 @@
# [ nil, true, false ].one? #=> true
# [ nil, true, 99 ].one?(Integer) #=> true
# [].one? #=> false
# ```
def one?: () -> bool
- | () { (Elem arg0) -> untyped } -> bool
+ | () { (Elem) -> boolish } -> bool
- def partition: () { (Elem arg0) -> untyped } -> [ ::Array[Elem], ::Array[Elem] ]
+ def partition: () { (Elem) -> boolish } -> [ ::Array[Elem], ::Array[Elem] ]
| () -> ::Enumerator[Elem, Return]
- def reject: () { (Elem arg0) -> untyped } -> ::Array[Elem]
+ def reject: () { (Elem) -> boolish } -> ::Array[Elem]
| () -> ::Enumerator[Elem, Return]
def reverse_each: () { (Elem arg0) -> untyped } -> ::Enumerator[Elem, Return]
| () -> ::Enumerator[Elem, Return]
@@ -286,11 +286,11 @@
def sort_by: () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
| () -> ::Enumerator[Elem, Return]
def take: (Integer n) -> ::Array[Elem]?
- def take_while: () { (Elem arg0) -> untyped } -> ::Array[Elem]
+ def take_while: () { (Elem) -> boolish } -> ::Array[Elem]
| () -> ::Enumerator[Elem, Return]
# Implemented in C++
# Returns the result of interpreting *enum* as a list of `[key, value]`
# pairs.
@@ -305,16 +305,22 @@
# (1..5).to_h {|x| [x, x ** 2]}
# #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25}
# ```
def to_h: () -> ::Hash[untyped, untyped]
- def each_slice: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
+ def each_slice: (Integer n) { (::Array[Elem]) -> untyped } -> NilClass
| (Integer n) -> ::Enumerator[::Array[Elem], Return]
- def find: (?Proc ifnone) { (Elem arg0) -> untyped } -> Elem?
- | (?Proc ifnone) -> ::Enumerator[Elem, Return]
+ interface _NotFound[T]
+ def call: () -> T
+ end
+ def find: () { (Elem) -> boolish } -> Elem?
+ | () -> ::Enumerator[Elem, Elem?]
+ | [T] (_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
+ | [T] (_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
+
def flat_map: [U] () { (Elem arg0) -> U } -> U
| () -> ::Enumerator[Elem, Return]
def map: [U] () { (Elem arg0) -> U } -> ::Array[U]
| () -> ::Enumerator[Elem, ::Array[untyped]]
@@ -390,15 +396,15 @@
| [U, Elem2, Return2] (::Enumerable[Elem2, Return2]) { ([Elem, Elem2 | nil]) -> U } -> nil
def chunk: () -> ::Enumerator[Elem, Return]
| [U] () { (Elem elt) -> U } -> ::Enumerator[[U, Array[Elem]], void]
- def chunk_while: () { (Elem elt_before, Elem elt_after) -> bool } -> ::Enumerator[::Array[Elem], void]
+ def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
- def slice_when: () { (Elem elt_before, Elem elt_after) -> bool } -> ::Enumerator[::Array[Elem], void]
+ def slice_when: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
- | () { (Elem elt) -> bool } -> ::Enumerator[::Array[Elem], void]
+ | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
- | () { (Elem elt) -> bool } -> ::Enumerator[::Array[Elem], void]
+ | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
end