From 0ced9ff85510238dd67c871ee539fdb412e41d8c Mon Sep 17 00:00:00 2001 From: AR Date: Tue, 10 Feb 2026 17:38:20 +0500 Subject: [PATCH] Update the `Dictionary.get` regarding the `default` argument & it's side effects Co-authored-by: Danil Alexeev --- doc/classes/Dictionary.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index 3e6e196e4c..e5363d7300 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -256,6 +256,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]