From 9324a7e867f75748bedd7fa4d21b4ee1c3bc0b7c Mon Sep 17 00:00:00 2001 From: AR Date: Wed, 4 Mar 2026 18:06:09 +0500 Subject: [PATCH] Update `Dictionary.get` regarding the `default` argument & it's side effects --- doc/classes/Dictionary.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index 79fbfff1756..6753398cf67 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -255,6 +255,13 @@ Returns the corresponding value for the given [param key] in the dictionary. If the [param key] does not exist, returns [param default], or [code]null[/code] if the parameter is omitted. + [b]Note:[/b] If the [param default] argument is computationally expensive or has unwanted side effects, consider using the [method has] method instead: + [codeblock] + # Always calls `expensive_function()`. + dict.get("key", expensive_function()) + # Calls `expensive_function()` only if the key does not exist. + dict.get("key") if dict.has("key") else expensive_function() + [/codeblock]