Skip to content

Latest commit

 

History

History
82 lines (57 loc) · 3.03 KB

class_packeddatacontainerref.rst

File metadata and controls

82 lines (57 loc) · 3.03 KB
github_url:hide

PackedDataContainerRef

Inherits: :ref:`RefCounted<class_RefCounted>` < :ref:`Object<class_Object>`

An internal class used by :ref:`PackedDataContainer<class_PackedDataContainer>` to pack nested arrays and dictionaries.

.. rst-class:: classref-introduction-group

Description

When packing nested containers using :ref:`PackedDataContainer<class_PackedDataContainer>`, they are recursively packed into PackedDataContainerRef (only applies to :ref:`Array<class_Array>` and :ref:`Dictionary<class_Dictionary>`). Their data can be retrieved the same way as from :ref:`PackedDataContainer<class_PackedDataContainer>`.

var packed = PackedDataContainer.new()
packed.pack([1, 2, 3, ["abc", "def"], 4, 5, 6])

for element in packed:
    if element is PackedDataContainerRef:
        for subelement in element:
            print("::", subelement)
    else:
        print(element)

# Prints:
# 1
# 2
# 3
# ::abc
# ::def
# 4
# 5
# 6
.. rst-class:: classref-reftable-group

Methods

:ref:`int<class_int>` :ref:`size<class_PackedDataContainerRef_method_size>`() |const|
.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Method Descriptions

.. rst-class:: classref-method

:ref:`int<class_int>` size() |const| :ref:`🔗<class_PackedDataContainerRef_method_size>`

Returns the size of the packed container (see :ref:`Array.size<class_Array_method_size>` and :ref:`Dictionary.size<class_Dictionary_method_size>`).