0

In the code below:

class A(val a: Int, val b: Int)

class B(a: Int, b: Int, val c: Int) extends A(a,b)

Are the variable a and b, or pointers to them, duplicated in memory when creating an instance of B?

Or more generally: does a B takes more memory than the memory size of A + an Int?

Juh_
  • 14,628
  • 8
  • 59
  • 92

1 Answers1

1

Take a look at Scala Constructor Parameters.

and

Do scala constructor parameters default to private val?

a and b in class B are not available outside the constructor of B and do not override anything in class A

Community
  • 1
  • 1
Yaneeve
  • 4,751
  • 10
  • 49
  • 87