daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. constructors in scala (primary/auxiliary/default primary)
  2. class Employee(val name: String, var salary: Double) {
  3.   def this() { this("John Q. Public", 0.0) }
  4. }
  5.    
  6. class Employee(n: String = "John Q. Public", s: Double = 0.0) {
  7.   val name = n
  8.   var salary = s
  9. }
  10.    
  11. class Employee(n: String, s: Double) {
  12.   def this() = this("John Q. Public", 0.0)
  13.   val name = n
  14.   var salary = s
  15. }
  16.    
  17. class Employee {
  18.   private var _name = "John Q. Public"
  19.   var salary = 0.0
  20.   def this(n: String, s: Double) { _name = n; salary = s; }
  21.   def name = _name      
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top