Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructors in scala (primary/auxiliary/default primary)
- class Employee(val name: String, var salary: Double) {
- def this() { this("John Q. Public", 0.0) }
- }
- class Employee(n: String = "John Q. Public", s: Double = 0.0) {
- val name = n
- var salary = s
- }
- class Employee(n: String, s: Double) {
- def this() = this("John Q. Public", 0.0)
- val name = n
- var salary = s
- }
- class Employee {
- private var _name = "John Q. Public"
- var salary = 0.0
- def this(n: String, s: Double) { _name = n; salary = s; }
- def name = _name
- }
Add Comment
Please, Sign In to add comment