If you want to know whether the label exists and has a "truthy" value, you can use the question mark:
if(current.maynotexist?) { // current.maynotexist exists and is non-zero, or points at a valid object }
If you just want to know if it exists, you can do
treenode maynotexist = current.labels["maynotexist"]; if( maynotexist ) { // the node exists, get its value with maynotexist.value }
However, you don't need the latter construction very often, for example, if you want to create the label if it does not exist, you can
current.labels.assert( "maynotexist" )
and if you assign a label with
current.maynotexist = 1;
it will be automatically created.
I want to set this condition for example if any label exist do nothing but if the label doesnt exist do something how can I do it?
if(!obj.MyLabel? && obj.MyLabel? != 0) { // Label not set // Do Something }
A "!" is a logical not.
This will return true only for strings that start with h:
text.startsWith("h")
This will return true for any string that starts with any letter other than h:
!text.startsWith("h")
I tried the ? method but it doesn't work for me
10 People are following this question.
© 1993- FlexSim Software Products, Inc. All Rights Reserved.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.