在 Scala 中当方法不需要接受参数时可定义成两种类型的方法
1. def width(): Int 空括号方法(empty-paren method)
2. def width: Int 无参数方法(parameterless method)
foreach和map的区别
注意foreach和map的使用,foreach不需要有返回值,但是map必须要有返回值
在 Scala 中当方法不需要接受参数时可定义成两种类型的方法
1. def width(): Int 空括号方法(empty-paren method)
2. def width: Int 无参数方法(parameterless method)
foreach和map的区别
注意foreach和map的使用,foreach不需要有返回值,但是map必须要有返回值