godotengine / godotengine/godot-docs

PackedByteArray passing by reference

Open
#7,026 4 comments 0 reactions 0 assignees View on GitHub
area:manual bug
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

The documentation v: stable (4.0) says:

> Built-in types are stack-allocated. They are passed as values. This means a copy is created on each assignment or when passing them as arguments to functions. The only exceptions are Arrays and Dictionaries, which are passed by reference so they are shared. (Packed arrays such as PackedByteArray are still passed as values.)

But `PackedByteArray` doesn't seems to be passing by value, it's behavior shows that it is being passed by reference:

![image](https://user-images.githubusercontent.com/15237374/226362695-ce3ffe49-6f71-4fbd-9d13-30a705171221.png)

This will print: `[1, 2, 3, 4, 5, 6]`, the same behavior as Array, it's not being copied, it's being referenced. So I think documentation is wrong.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.