fork download
trait DeepCloneable[A] { self: A =>
    def deepClone: A
}
 
class Egg(size: Int) extends DeepCloneable[Egg] {
    def deepClone = new Egg(size)
}
 
object Main extends App {
    val e = new Egg(3)
    println(e)
    println(e.deepClone)
}
Success #stdin #stdout 0.31s 247488KB
stdin
Standard input is empty
stdout
Egg@a981ca
Egg@8814e9