I mentioned it in the thread above but I believe t...
# pattern-matching
r
I mentioned it in the thread above but I believe the problem we first have to solve is unrelated to when. The pattern matching piece we want to implement is the expression Predicate desugaring. That in a when is any arbitrary Boolean expression that takes you down the RHS with the destructured scope. Approaching the problem with this example, is the same as approaching the problem without when:
Copy code
fun main() {
  val subject = Person(0, "Jane")
  val result =
    when (subject) {
      case(Person(_, y)) where { y == "Jane" } -> true
      else -> false
    }
  println(result) // should print true
}

fun main() {
  val subject = Person(0, "Jane")
  val Person(_, y) = subject
  println(result) // should print Jane and it's typed to String
}