GDictionary

    A built-in data structure that holds key-value pairs.

    Dictionary.swift:35
    class GDictionary

    Dictionaries are associative containers that contain values referenced by unique keys. Dictionaries will preserve the insertion order when adding new entries. In other programming languages, this data structure is often referred to as a hash map or an associative array.

    You can define a dictionary by placing a comma-separated list of key: value pairs inside curly braces {}.

    Creating a dictionary:

    You can access a dictionary’s value by referencing its corresponding key. In the above example, points_dict["White"] will return 50. You can also write points_dict.White, which is equivalent. However, you’ll have to use the bracket syntax if the key you’re accessing the dictionary with isn’t a fixed string (such as a number or variable).

    In the above code, points will be assigned the value that is paired with the appropriate color selected in my_color.

    Dictionaries can contain more complex data:

    To add a key to an existing dictionary, access it like an existing key and assign to it:

    Finally, dictionaries can contain different types of keys and values in the same dictionary:

    The keys of a dictionary can be iterated with the for keyword:

    Citizens in SwiftGodot

    Conformances

    • protocol ContentVariantRepresentable

      Some of Godot’s builtin classes use ContentType for storage. This needs to be public because it affects their initialization, but SwiftGodot users should never need to conform their types toContentVariantRepresentable.

    • protocol Copyable

      A type whose values can be implicitly or explicitly copied.

    • protocol CustomDebugStringConvertible

      A type with a customized textual representation suitable for debugging purposes.

    • protocol CustomStringConvertible

      A type with a customized textual representation.

    • protocol Equatable

      A type that can be compared for value equality.

    • protocol Escapable
    • protocol VariantRepresentable

      Types that conform to VariantRepresentable can be stored directly in Variant with no conversion. These include all of the Variant types from Godot (for example GString, Rect, Plane), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.

    • protocol VariantStorable

      Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.

    Typealiases

    Type members

    Instance members

    Type features

    Instance features