Update Array#2987
Conversation
786a245 to
31a4a54
Compare
| # | ||
| alias any? all? | ||
| def any?: () -> bool | ||
| | (_Pattern[E] pattern) -> bool |
There was a problem hiding this comment.
TODO: Use RBS::Ops:_Matches
1eef064 to
0fa718e
Compare
| def bsearch: () -> ::Enumerator[E, E?] | ||
| | () { (E) -> (true | false) } -> E? | ||
| | () { (E) -> ::Integer } -> E? | ||
| def bsearch: () { (E element) -> (Numeric | bool?) } -> E? |
There was a problem hiding this comment.
I'm not sure if this works for actual type checkers, but these definitions are not equivalent.
Returning both true | false and Integer from a block is not allowed to bsearch, I think.
There was a problem hiding this comment.
[…].bsearch { it.positive? and it } # false | IntegerThere was a problem hiding this comment.
https://docs.ruby-lang.org/en/4.0/language/bsearch_rdoc.html#label-Binary+Searching
The block should not mix the modes by sometimes returning true or false and other times returning a numeric value, but this is not checked.
cc52661 to
4691c6d
Compare
2f1d30d to
21d3886
Compare
sampersand
left a comment
There was a problem hiding this comment.
Did final check, should good
dfe3641 to
a814469
Compare
| # Array](rdoc-ref:Array@Methods+for+Creating+an+Array). | ||
| # | ||
| def self.[]: [U] (*U) -> ::Array[U] | ||
| def self.[]: [U] (*U) -> Array[U] # this technically returns a subclass, but `instance(self)` isn't a thing |
There was a problem hiding this comment.
I think instance would work. However instance[U] isn't a thing.
Co-authored-by: Soutaro Matsumoto <matsumoto@soutaro.com>
This PR completely updates
Array's signatures, and rewrites the test harness to work with it.Note that there's some
# where E: ...comments strewn about in the code. This marks places where, when we eventually get around to implementing thewhereclause, we should implement them in the Array.