question

TYLin avatar image
0 Likes"
TYLin asked Phil BoBo edited

Map.find() doesn't work

1693387651584.png

why this code didn't work?

I want to use .find() to check if the key exist in the map.

or how should I build my code. Thanks!


FlexSim 23.2.0
codemap
1693387651584.png (10.7 KiB)
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

The script console can't return an iteration key value pair. Use:

Map A;
A["a"]=10;
var iter=A.find("a");
if (iter)
    return 1;  // or iter.value
else
    return 0;  //or nullvar
5 |100000

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