question

David Seo avatar image
0 Likes"
David Seo asked Matthew Gillespie commented

slot.Type? == item.Type?; "?" means in both sides?

In slot assignment rule...

I want to know what's the meaning of both sides "?".

What type of operator? And what's the meaning of it?

And I want to know also about "?.".

FlexSim 21.2.3
nullnullish
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Matthew Gillespie commented

The question mark operator is something you can put at the end of a label name when getting a label value with the treenode.labelName syntax so that it doesn't throw an exception if the label doesn't exist. You can view the documentation here: https://docs.flexsim.com/en/21.2/Reference/CodingInFlexSim/FlexScriptAPIReference/Tree/treenode.html#Property-labelProperties

The 2 question marks are here so that it doesn't throw exceptions if all your slots don't have a Type label or if all your items don't have a Type label.

?. is similar, but makes it so that no exception is thrown if the thing before the ?. operator doesn't exist. For example, here the ?. makes it so you don't see an exception even though the treenode doesn't exist.

treenode x;
return x?.color;
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

David Seo avatar image David Seo commented ·

Thanks a lot, @Matthew Gillespie

I could not find any page using '? operator' key word in manual.

I found only '?.'. Thank you again.

? and # operator are flexsim's only? or new one in C++?

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ David Seo commented ·

@David Seo

# is FlexSim only, as far as I know. The ?. syntax is called optional chaining and is in other languages like JavaScript or Swift.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.