You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type `(::Cat | ::Dog)` does not have method `meow`
I guess, this can be justified by the type definition of Array#select but this is not exactly useful. Filtering is used all the time to narrow down collection to a subset with certain properties and type is often that property.
Is there a way to narrow down the type of the collection? Or do I have to rewrite it with next unless pet.is_a?(cat) in the each` block?
The text was updated successfully, but these errors were encountered:
If blocks can have overloads – ideally with ruby/rbs#1875, then RBS can guide type checkers on this type narrowing.
Take Enumerable#reject for a nice example:
Suppose we have the following code:
And here's how we might use it:
Steep is having issue with this code:
I guess, this can be justified by the type definition of
Array#select
but this is not exactly useful. Filtering is used all the time to narrow down collection to a subset with certain properties and type is often that property.Is there a way to narrow down the type of the collection? Or do I have to rewrite it with
next unless pet.is_a?(cat) in the
each` block?The text was updated successfully, but these errors were encountered: