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

[3.x] Add a get_or_add method to Dictionary #88345

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

SysError99
Copy link
Contributor

This follows #78095 that adds get_or_add method to Dictionary for 3.x branch. This is a very useful function for setting up new parameters into the dictionary or keep using old values from it.

@SysError99 SysError99 requested review from a team as code owners February 14, 2024 22:07
Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

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

Pretty much identical to master.

<argument index="0" name="key" type="Variant" />
<argument index="1" name="default" type="Variant" default="null" />
<description>
Gets a value and ensures the key is set. If the [param key] exists in the dictionary, this behaves like [method get]. Otherwise, the [param default] value is inserted into the dictionary and returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

To my personal annoyance and a few others, param does not exist in 3.x.

Suggested change
Gets a value and ensures the key is set. If the [param key] exists in the dictionary, this behaves like [method get]. Otherwise, the [param default] value is inserted into the dictionary and returned.
Gets a value and ensures the key is set. If the [code]key[/code] exists in the dictionary, this behaves like [method get]. Otherwise, the [code]default[/code] value is inserted into the dictionary and returned.

@AThousandShips
Copy link
Member

Since this is a functionally identical backport I'd say to add a co-author to this

@AThousandShips

This comment was marked as outdated.

@AThousandShips

This comment was marked as outdated.

Co-authored-by: Aaron Franke <arnfranke@yahoo.com>
@lawnjelly lawnjelly merged commit 1a9b5b7 into godotengine:3.x Apr 4, 2024
13 checks passed
@lawnjelly
Copy link
Member

Thanks!

@akien-mga akien-mga modified the milestones: 3.x, 3.6 Apr 4, 2024
@SysError99 SysError99 deleted the 3.x-get_or_add branch April 5, 2024 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants