0

I have 2 classes.

  Class A {
      var something : String =_
   }
   Class B extends A{
      var somethingElse : String =_
   }

I will instantiate these 2 classes separately.

var a = new A 

a.something ="test me"

var b = new B

before start assigning values to b I want to copy content of object a into b . Is it possible to do this in scala using reflection or any third party API?

Mario Galic
  • 47,285
  • 6
  • 56
  • 98
D P
  • 153
  • 2
  • 12
  • interesting, why do you prefer `var something: String = _` instead of `class A(something: String)` – prayagupa Jun 19 '18 at 01:01
  • I will use reflection to create class A from a key value pair and gain using another reflection to create Class b which is everything from A and some extra fields. – D P Jun 19 '18 at 01:30

0 Answers0