Created
September 3, 2024 04:31
-
-
Save nagat01/6246453e2e4ec5b8f58f28ac91896643 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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