question mark meaning

papawo
papawo Member, Developers Posts: 206 PRO
what does a question mark means in FS coding?

Comments

  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,274 image
    It's a ternary operator: https://en.wikipedia.org/wiki/?:

    Basically, if you type:
    var x = predicate ? 1 : 2;

    Then if predicate is true, x is set to 1, if it is false, x is set to 2, and if predicate is not a boolean, an error is thrown.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • papawo
    papawo Member, Developers Posts: 206 PRO
    thank you. :)