From 37248d7c87cc4e7350cb29159f5c22a602d489e7 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Fri, 20 Jan 2023 14:36:52 -0500 Subject: Add `@GlobalScope` `is_same(a, b)` and `Variant::identity_compare()` --- doc/classes/@GlobalScope.xml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'doc') diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 2be15d5100..a859f36f3e 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -525,6 +525,31 @@ Returns [code]true[/code] if [param x] is a NaN ("Not a Number" or invalid) value. + + + + + + Returns [code]true[/code], for value types, if [param a] and [param b] share the same value. Returns [code]true[/code], for reference types, if the references of [param a] and [param b] are the same. + [codeblock] + # Vector2 is a value type + var vec2_a = Vector2(0, 0) + var vec2_b = Vector2(0, 0) + var vec2_c = Vector2(1, 1) + is_same(vec2_a, vec2_a) # true + is_same(vec2_a, vec2_b) # true + is_same(vec2_a, vec2_c) # false + + # Array is a reference type + var arr_a = [] + var arr_b = [] + is_same(arr_a, arr_a) # true + is_same(arr_a, arr_b) # false + [/codeblock] + These are [Variant] value types: [code]null[/code], [bool], [int], [float], [String], [StringName], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i], [Rect2], [Rect2i], [Transform2D], [Transform3D], [Plane], [Quaternion], [AABB], [Basis], [Projection], [Color], [NodePath], [RID], [Callable] and [Signal]. + These are [Variant] reference types: [Object], [Dictionary], [Array], [PackedByteArray], [PackedInt32Array], [PackedInt64Array], [PackedFloat32Array], [PackedFloat64Array], [PackedStringArray], [PackedVector2Array], [PackedVector3Array] and [PackedColorArray]. + + -- cgit v1.2.3