• Hi Guest!

    We are extremely excited to announce the release of our first Beta1.1 and the first release of our Public AddonKit!
    To participate in the Beta, a subscription to the Entertainer or Creator Tier is required. For access to the Public AddonKit you must be a Creator tier member. Once subscribed, download instructions can be found here.

    Click here for information and guides regarding the VaM2 beta. Join our Discord server for more announcements and community discussion about VaM2.
  • Hi Guest!

    VaM2 Resource Categories have now been added to the Hub! For information on posting VaM2 resources and details about VaM2 related changes to our Community Forums, please see our official announcement here.

? operator in float? -- what does it do?

AWWalker

Another White Walker (AWWalker)
Featured Contributor
Joined
Jun 1, 2020
Messages
435
Reactions
2,885
@MacGruber and @lfe

Searching for something with a ? in it on the google, well, it doesn't really respond correctly. In @lfe 's extra auto gen 3.0, the following line of code:

C#:
public float? NextMorphValue(float? velocityRaw, float friction)

What does the ? do? Is that for dynamic variables or something? Trying to do the same sort of thing so I can make a plugin that stores all my favorite morphs in one session, instead of hunting down the additional morphs in the morphs GUI, or manually creating entries for each in a plugin. Then find how to store them in a reusable way.

Self taught coder, so what i don't know yet, i don't know :)
 
The irony of questions about question marks. The struggle is real.

C# has a numer of places that you can use question marks.

This one is to allow the return value to be a float that could be null, and the parameter can take a float that may be null as well. I probably did this so that I could distinguish between 'null' (could not calculate one) and '0' (next value should be 0).

More on the nullable type here:
 
ok, that makes sense now. And the IDE is hinting that when i remove the ? and telling me it could return null, it can't be null etc... cool.
 
Back
Top Bottom