• Hi Guest!

    This is a notice regarding recent upgrades to the Hub. Over the last month, we have added several new features to improve your experience.
    You can check out the details in our official announcement!

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

AWWalker

Another White Walker (AWWalker)
Featured Contributor
Messages
435
Reactions
2,626
Points
93
Website
www.patreon.com
@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