- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Accessing val in parent trait
Mon, 2010-11-08, 20:54
Is is possible to access a val in a parent trait? Here's roughly what I like to do,
trait Parent { val foo = "foo"}
class Child extends Parent { override val foo = if (something) "bar" else Parent.this.foo}
... which doesn't compile. Any other way to do this?
alex
trait Parent { val foo = "foo"}
class Child extends Parent { override val foo = if (something) "bar" else Parent.this.foo}
... which doesn't compile. Any other way to do this?
alex
Mon, 2010-11-08, 22:07
#2
Re: Accessing val in parent trait
Thanks Jason & Paul. I'll go with a def for now.
alex
On Mon, Nov 8, 2010 at 12:49 PM, Paul Phillips <paulp@improving.org> wrote:
alex
On Mon, Nov 8, 2010 at 12:49 PM, Paul Phillips <paulp@improving.org> wrote:
On Mon, Nov 08, 2010 at 11:54:19AM -0800, Alex Boisvert wrote:
> Is is possible to access a val in a parent trait? Here's roughly what
> I like to do,
https://lampsvn.epfl.ch/trac/scala/ticket/1938
"traits should be able to call super on fields"
--
Paul Phillips | Simplicity and elegance are unpopular because
Apatheist | they require hard work and discipline to achieve
Empiricist | and education to be appreciated.
pp: i haul pills | -- Dijkstra
On Mon, Nov 08, 2010 at 11:54:19AM -0800, Alex Boisvert wrote:
> Is is possible to access a val in a parent trait? Here's roughly what
> I like to do,
https://lampsvn.epfl.ch/trac/scala/ticket/1938
"traits should be able to call super on fields"