-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
c_sharp_variant.rst: add more examples, fix explicit vs. implicit #8878
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
Conversation
raulsntos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the effort to improve the Variant documentation. I want to be careful about how we explain the type to avoid encouraging its usage more than necessary, I hope I wasn't too nit-picky.
| a ``Godot.Variant`` to a C# type. Since the ``Godot.Variant`` type contains implicit conversions | ||
| defined for all the supported types, calling these methods directly is usually not necessary. | ||
| Converting from a Variant-compatible C# type to ``Godot.Variant`` can be done using implicit | ||
| conversions. Also available are ``CreateFrom`` method overloads and the generic ``Variant.From<T>`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| conversions. Also available are ``CreateFrom`` method overloads and the generic ``Variant.From<T>`` | |
| conversions. You also have ``CreateFrom`` method overloads and the generic ``Variant.From<T>`` |
Or
| conversions. Also available are ``CreateFrom`` method overloads and the generic ``Variant.From<T>`` | |
| conversions. There are also ``CreateFrom`` method overloads and the generic ``Variant.From<T>`` |
"Also available are" sounds clunky in English IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW to me (en-us) it's a common phrase that implies the first (previous) option is the default. also available shows up elsewhere in the docs too, just not followed with are in particular. I do think There are also works fine though, happy to change it. (Which is now pushed.)
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
6c7d503 to
c2e68a8
Compare
raulsntos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks great already, thank you for improving the C# Variant documentation. I only left a minor nit-pick.
|
Whoops, should have squashed. Anyway, merged! Thanks, and thanks for the reviews everyone. |
c_sharp_variant.rst: add more examples, fix explicit vs. implicit (cherry picked from commit 664b739)
|
Cherry-picked to 4.2 in #9648. |
This page deserves examples and a little correction about the implicit vs. explicit conversions.
The example about comparing two
Variants using.Objand==might seem oddly specific, but it's come up at least twice now in the C# discord help channel.I also assumed a while back that
.As<T>would behave more like aa as B, and the explicit conversion(B)awould throw an exception, but it's not the case (and thePacked{Type}Arrayempty array case is interesting), so worth mentioning IMO, but not sure in how much detail.