X Tutup
Skip to content

Fix typeof example in @GlobalScope docs#106768

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
Leftyluupy:typeof-example
Dec 8, 2025
Merged

Fix typeof example in @GlobalScope docs#106768
Repiteo merged 1 commit intogodotengine:masterfrom
Leftyluupy:typeof-example

Conversation

@Leftyluupy
Copy link
Contributor

@Leftyluupy Leftyluupy commented May 24, 2025

I added a (hopefully) more relevant example to the typeof() method in the @globalscope documentation, as per this issue: godotengine/godot-docs#10957

bugsquad edit:
Closes godotengine/godot-docs#10957.

@Castro1709
Copy link

Castro1709 commented May 24, 2025

I would say that's it's better if the example compared to the returned value of typeof to the Variant.Type enum, and not just the int value.
For example this will be the corrected version of the current documentation:

var json = JSON.new()
json.parse("[1, 2, 3, 5]")
var result = json.get_data()
if typeof(result) == TYPE_ARRAY:
    print(result[0])
else:
    print("Unexpected result!")

Also, I think it's better if we keep the old example because it's a good case when you could use typeof. because it's checking the type of a method that returns variant.

@Leftyluupy
Copy link
Contributor Author

I would say that's it's better if the example compared to the returned value of typeof to the Variant.Type enum, and not just the int value. For example this will be the corrected version of the current documentation:

var json = JSON.new()
json.parse("[1, 2, 3, 5]")
var result = json.get_data()
if typeof(result) == TYPE_ARRAY:
    print(result[0])
else:
    print("Unexpected result!")

Also, I think it's better if we keep the old example because it's a good case when you could use typeof. because it's checking the type of a method that returns variant.

Thank you! I agree; I was just trying to follow the previous type example just above it in the documentation. I have modified it (I think), back to your suggestion.

@Mickeon
Copy link
Member

Mickeon commented Jun 6, 2025

This needs a rebase after:

@Leftyluupy
Copy link
Contributor Author

This needs a rebase after:

I tried to resolve a conflict and add tabs according to this comment, but I am not sure about that last commit. I don't know why it says to merge the master branch into my typeof branch; I thought it was going the other way. Sorry!

@Repiteo Repiteo modified the milestones: 4.5, 4.x Sep 18, 2025
Copy link
Member

@kleonc kleonc left a comment

Choose a reason for hiding this comment

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

LGTM, basically reverts incorrect change from #99876.

@kleonc kleonc modified the milestones: 4.x, 4.6 Dec 5, 2025
Co-Authored-By: Leftyluupy <99181178+leftyluupy@users.noreply.github.com>
@akien-mga akien-mga changed the title Typeof example in @GlobalScope Fix typeof example in @GlobalScope docs Dec 8, 2025
@Repiteo Repiteo merged commit 8e2feb7 into godotengine:master Dec 8, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 8, 2025

Thanks! Congratulations on your first merged contribution! 🎉

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.

typeof example doesn't use typeof

8 participants

X Tutup