Last active
March 29, 2020 22:17
-
-
Save p-pavel/0f7b78c652d62b964a0ae8818c3dfc36 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
import scala.reflect.ClassTag | |
import scala.compiletime._ | |
inline def alloc[T: ClassTag](n: Int) = if n > 0 then new Array[T](n) else error("Array size should be positive") | |
def main(args: Array[String]): Unit = { | |
println(alloc[Int](100).length) | |
alloc[Int](0) // не компилируется | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment