Skip to content
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

Return null instead of throwing of Widget.child does not exist #692

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

whitebyte
Copy link
Contributor

Closes #691
I found only one instance of .child method override

src/dlangui/core/collections.d Outdated Show resolved Hide resolved
@@ -248,6 +248,17 @@ struct ObjectList(T) {
assert(index >= 0 && index < _count, "child index out of range");
return _list[index];
}
/// get item by index. Returns null if item not found
inout(T) tryGet(int index) @safe inout nothrow {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is inout really necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I didn't think too much about it. I'm following the pattern. Since get is inout I decided to make tryGet inout as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a quick check - yes, inout is indeed necessary

@GrimMaple
Copy link
Collaborator

Thank you for your work! :)

@GrimMaple GrimMaple merged commit 986c1fc into buggins:master Nov 26, 2024
4 checks passed
@GrimMaple
Copy link
Collaborator

I think my sleepy head just did something that I didn't intend on - I intended to squash and merge. Welp, sleep is importnat folks x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Widget.child throws if there is no child
2 participants