Alternative typing in a constructor/parameter

this join the union type discussion i think

fun timeTwo(number: Int|String|Double) {
  if (number is Int) {
    return number * 2
  }
  else {
      return number.toInt()
  }
}
1 Like