Skip to content

Instantly share code, notes, and snippets.

@nagat01
Created September 3, 2024 04:31
Show Gist options
  • Save nagat01/6246453e2e4ec5b8f58f28ac91896643 to your computer and use it in GitHub Desktop.
Save nagat01/6246453e2e4ec5b8f58f28ac91896643 to your computer and use it in GitHub Desktop.
type A = [T] =>> T match { case String => Int; case Int => String }
def f1[T](a: T): A[T] = a match
case a: String => a.toInt
case a: Int => a.toString
def f2[T](a: T): T match { case String => Int; case Int => String } = a match
case a: String => a.toInt
case a: Int => a.toString
def f3[T](a: T) = a match
case a: String => a.toInt
case a: Int => a.toString
@main def main =
println(f1(0).getClass)
println(f2(0).getClass)
println(f3(0).getClass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment