This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: Can a trait override a method in the class it's supposed to be mixed into?

1 reply
Seth Tisue
Joined: 2008-12-16,
User offline. Last seen 34 weeks 3 days ago.

>>>>> "Paul" == Paul Phillips writes:

Paul> trait T extends C { override def x = "bar" }

Great, thanks! (I had just assumed a trait couldn't extend a class.)

David Pollak
Joined: 2008-12-16,
User offline. Last seen 42 years 45 weeks ago.
Re: Can a trait override a method in the class it's supposed to
I would have hoped that these two would have worked:

trait R {
  self: C =>
  override def foo: String = "WOof"
}

trait B {
  self: {def foo: String} =>
  override def foo: String = "WOof"
}

The latter, especially, seems to be the most flexible.

Thanks,

David

On Wed, Dec 31, 2008 at 8:51 AM, Seth Tisue <seth [at] tisue [dot] net> wrote:
>>>>> "Paul" == Paul Phillips <paulp [at] improving [dot] org> writes:

 Paul> trait T extends C { override def x = "bar" }

Great, thanks!  (I had just assumed a trait couldn't extend a class.)

--
Seth Tisue / http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/



--
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland