00006 Scala Parameter
默认参数值
def log(message: String, level: String = "INFO") = println(s"$level: $message")
log("System starting") // prints INFO: System starting
log("User not found", "WARNING") // prints WARNING: User not found// Point.scala
class Point(val x: Double = 0, val y: Double = 0)// Main.java
public class Main {
public static void main(String[] args) {
Point point = new Point(1); // does not compile
}
}命名参数
最后更新于
这有帮助吗?