Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typed arrays documentation #79075

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Jul 5, 2023

  1. Extend the typed array constructor documentation.
  2. Correct documentation of get_typed_*() methods.

The constructor is verbose and a bit confusing, I've seen questions about it on Discord several times.

@dalexeev dalexeev added topic:core topic:gdscript documentation cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Jul 5, 2023
@dalexeev dalexeev added this to the 4.2 milestone Jul 5, 2023
@dalexeev dalexeev requested a review from a team as a code owner July 5, 2023 17:25
</description>
</method>
<method name="get_typed_script" qualifiers="const">
<return type="Variant" />
<description>
Returns the script associated with a typed array tied to a class name.
Returns the script associated with the typed array. This method returns a [Script] instance or [code]null[/code].
Copy link
Member Author

@dalexeev dalexeev Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it returns Object#null, but I think it's a bug.

print(null) # <null>
print([].get_typed_script()) # <Object#null>

Copy link
Member Author

@dalexeev dalexeev Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I'm not sure if this is a bug, this is the behavior of all Ref<T> properties and method return values. Should we draw the reader's attention to this difference?

var sprite := Sprite2D.new()
print(sprite.texture) # <Object#null>
print(sprite.texture == null) # true
print(is_same(sprite.texture, null)) # false
print(typeof(sprite.texture)) # 24
print(typeof(null)) # 0
Suggested change
Returns the script associated with the typed array. This method returns a [Script] instance or [code]null[/code].
Returns the script associated with the typed array. This method returns a [Script] instance (can be invalid).

@Mickeon
Copy link
Contributor

Mickeon commented Jul 25, 2023

Also see #69451 in the eventuality that it will be taken a look at.

@YuriSizov YuriSizov modified the milestones: 4.2, 4.3 Nov 13, 2023
@YuriSizov YuriSizov added enhancement cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release and removed cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Nov 13, 2023
@akien-mga akien-mga merged commit a27d963 into godotengine:master Apr 8, 2024
13 checks passed
@dalexeev dalexeev deleted the doc-typed-arrays branch April 8, 2024 09:28
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typed Array constructor has no clear documentation about how it should be used
6 participants