fork(1) download
  1. trait DeepCloneable[A] { self: A =>
  2. def deepClone: A
  3. }
  4.  
  5. class Egg(size: Int) extends DeepCloneable[Egg] {
  6. def deepClone = new Egg(size)
  7. }
  8.  
  9. object Main extends App {
  10. val e = new Egg(3)
  11. println(e)
  12. println(e.deepClone)
  13. }
Success #stdin #stdout 0.31s 247488KB
stdin
Standard input is empty
stdout
Egg@a981ca
Egg@8814e9