Packages and Imports
Selective Import
Import a few names from the standard library.
Selective Import
ImportMath.scala
import scala.math.{min, max}
object Main {
def main(args: Array[String]): Unit = {
val x =
val lo = min(x, 5)
val hi = max(x, 5)
println("lo=" + lo)
println("hi=" + hi)
}
}
import scala.math.{min, max}
object Main {
def main(args: Array[String]): Unit = {
val x =
val lo = min(x, 5)
val hi = max(x, 5)
println("lo=" + lo)
println("hi=" + hi)
}
}
import scala.math.{min, max}
object Main {
def main(args: Array[String]): Unit = {
val x =
val lo = min(x, 5)
val hi = max(x, 5)
println("lo=" + lo)
println("hi=" + hi)
}
}
import-math
A selective import brings only the listed names into scope. Here `min` and `max` come from `scala.math` and can be called without a prefix.