The is-set operator on values and calculations

The complete source of operators_isset.ek9, compiled by the EK9 compiler. Shown on operators.html.

#!ek9
defines module site.operators.isset

  defines program

    IsSet()
      stdout <- Stdout()

      name1 <- "Bill"
      name2 <- "Ted"
      name1Set <- name1? //results in true

      name3 as String: String()
      name3Set <- name3? //results in false

      name4 <- String()
      name4Set <- name4? //results in false

      //Note the validity of the calculation is been checked here not the actual result.
      //The use of the '( ... )' is important here. The ? applies to the result.

      validCalculation <- (name1 < name2)?
      //results in true - because the calculation was valid not because Bill is Less than Ted
      invalidCalculation <- (name1 < name3)?
      //results in false - because the calculation was invalid name is not set

      stdout.println(`${name1Set} ${name3Set} ${name4Set}`)
      stdout.println(`${validCalculation} ${invalidCalculation}`)

Download operators_isset.ek9

Output

true false false
true false