summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-07-22 10:22:16 +0200
committerGitHub <noreply@github.com>2019-07-22 10:22:16 +0200
commite448fdad159a07ee855630ee4d3b0328a94998e0 (patch)
treef969cf306d5c423973ab990ae4133e79965704e2
parent92b65ff0c604d35dd9960310b772cba574e32926 (diff)
parent4840d36654aae176c2273cd20e622130d304b03d (diff)
Merge pull request #30720 from Calinou/doc-improve-variant
Improve the Variant class documentation
-rw-r--r--doc/classes/Variant.xml13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/classes/Variant.xml b/doc/classes/Variant.xml
index eb07c70cc6..522e131b45 100644
--- a/doc/classes/Variant.xml
+++ b/doc/classes/Variant.xml
@@ -5,6 +5,19 @@
</brief_description>
<description>
A Variant takes up only 20 bytes and can store almost any engine datatype inside of it. Variants are rarely used to hold information for long periods of time. Instead, they are used mainly for communication, editing, serialization and moving data around.
+ A Variant:
+ - Can store almost any datatype.
+ - Can perform operations between many variants. GDScript uses Variant as its atomic/native datatype.
+ - Can be hashed, so it can be compared quickly to other variants.
+ - Can be used to convert safely between datatypes.
+ - Can be used to abstract calling methods and their arguments. Godot exports all its functions through variants.
+ - Can be used to defer calls or move data between threads.
+ - Can be serialized as binary and stored to disk, or transferred via network.
+ - Can be serialized to text and use it for printing values and editable settings.
+ - Can work as an exported property, so the editor can edit it universally.
+ - Can be used for dictionaries, arrays, parsers, etc.
+ [b]Containers ([Array] and [Dictionary]):[/b] Both are implemented using variants. A [Dictionary] can match any datatype used as key to any other datatype. An [Array] just holds an array of Variants. Of course, a Variant can also hold a [Dictionary] and an [Array] inside, making it even more flexible.
+ Modifications to a container will modify all references to it. A [Mutex] should be created to lock it if multi-threaded access is desired.
</description>
<tutorials>
</tutorials>