But I want to override... and add something ("adding something to the
original sitemap, ")
Allright, with your example I can express my question perfectly!
If you have
trait Foo {
def bar: String
}
trait MegaFoo extends Foo {
lazy val bar = "Hello"
}
And then want to create a trait that extends MegaFoo and override bar,
adding something to that string... i get the next results:
With:
trait SuperMegaFoo extends MegaFoo {
override lazy val bar = bar + "Super Duper"
}
Compiler:
(fragment of overrideTest.scala):10: error: recursive lazy value bar
needs type
override lazy val bar = bar + "Super Duper"
With:
trait SuperMegaFoo extends MegaFoo {
override lazy val bar:String = bar + "Super Duper"
}
Compiler: (Crashhhh!)
java.lang.StackOverflowError
at scala.StringBuilder.append(StringBuilder.scala:242)
at scala.StringBuilder.<init>(StringBuilder.scala:54)
at scala.StringBuilder.<init>(StringBuilder.scala:41)
at Main$$anon$2$SuperMegaFoo$class.bar((virtual file):14)
at Main$$anon$2$$anon$1.bar((virtual file):17)
at Main$$anon$2$SuperMegaFoo$class.bar((virtual file):14)
at Main$$anon$2$$anon$1.bar((virtual file):17)
at Main$$anon$2$SuperMegaFoo$class.bar((virtual file):14)
With:
trait SuperMegaFoo extends MegaFoo {
override lazy val bar:String = super.bar + "Super Duper"
}
Compiler:
(fragment of overrideTest.scala):10: error: super may be not be used
on lazy value bar
override lazy val bar:String = super.bar + "Super Duper"
With
trait SuperMegaFoo extends MegaFoo {
override val bar:String = super.bar + "Super Duper"
}
Compiler:
(fragment of overrideTest.scala):10: error: super may be not be used
on lazy value bar
override val bar:String = super.bar + "Super Duper"
Finally, dropping the lazzy:
trait SuperMegaFoo extends MegaFoo {
override val bar:String = bar + "Super Duper"
}
Compiler:
(fragment of overrideTest.scala):10: error: error overriding lazy
value bar in trait MegaFoo of type java.lang.String;
value bar must be declared lazy to override a concrete lazy value
So this is my trouble(i get all this cases if i try to override
sitemap from the metaprotouser to add new items to the sitemap) i cant
drop the lazy, i cant use super in lazy so what am I doing something
wrong?
On Jul 8, 10:23 am, David Pollak <
feeder.of.the.be...@gmail.com>
wrote:
> Beginning Scalahttp://
www.apress.com/book/view/1430219890