-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add callable support for find
and rfind
Array
methods
#95449
Conversation
Looks like I need to write tests. Also, I think my |
Where are tests for |
c4cda77
to
78a8275
Compare
find
, rfind
, and count
Array
methods
78a8275
to
46aee85
Compare
@AThousandShips resolved. Good catch. Also realized that A few remaining questions:
|
46aee85
to
715204a
Compare
Here Once you've fixed the callable argument issue we can see what the doc things are |
I fixed the const issue. I was going to put the test in there, but I didn't see one for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fix CI
715204a
to
8d8eed0
Compare
I've added the tests, and fixed the bind method. Good catch. Makes sense that that failed. |
8d8eed0
to
fe0d1c6
Compare
Sorry, I caught a typo. |
fe0d1c6
to
e3cbb12
Compare
Tests run during CI, right? |
If I added these changes, would I have to go through the approval process again?... |
No. |
5f59e1a
to
45dd343
Compare
The CI says there's a duplicate declaration of Array? What? |
45dd343
to
fc13a10
Compare
oops. |
fc13a10
to
cc5ecb7
Compare
@Nazarwadim done. |
To me |
I agree, but the consensus seemed to be to remove it. |
cc5ecb7
to
648a3ef
Compare
@Nazarwadim @dalexeev done. |
648a3ef
to
89491f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have significant demand as there's been already at least 3 PRs attempting to implement this, and the linked proposal is somewhat consensual.
The proposed API seems fine to me. I didn't review implementation details but others did, so I think this is good to go.
Thanks! |
I have implemented a number of methods for using callables with:
find
(find_custom
)rfind
(rfind_custom
)count
(count_cusom
)I implemented these in a previous PR, but I accidentally deleted it when cleaning up my github, so I am doing it again. Also, I am better at contributing to codebases now, and working with C++.
On the last PR,
count_custom
could just bereduce
, and indeed that's what it uses internally, but I would argue that this is okay, as there is precedent for using simple wrapper methods to avoid confusion with less experienced programmers and work with their intuition (has
relies onfind
,append
is an alias forpush_back
). On the other hand, instead ofmax_custom
andmin _custom
, you're instructed to use reduce instead, so there is precedence against, too.Closes godotengine/godot-proposals#6889