Are multiple self-types possible?

I want to do the following, but the self-type line just doesn't compile. Do I have this syntax wrong or is this just impossible?

trait A {
  def aValue = 1
}
trait B {
  def bValue = 1
}
trait C {
  a : A, b : B =>
  def total = a.aValue + b.bValue
}

class T extends C with A with B { ...

Answers


You can have a single self-type which is a compound type.

Try this:

trait A {
  def aValue = 1
}
trait B {
  def bValue = 1
}
trait C {
  self: A with B =>
  def total = aValue + bValue
}

class ABC extends A with B with C

Need Your Help

Segmentation fault in linux driver

c linux-kernel segmentation-fault linux-device-driver

I'm trying to write a linux driver. The kernel version is 2.4.18 and the distribution is Red Hat linux 8.0.

Background picture is “blinking” when the screen orientation is changed

ios orientation

I would like to change the background picture of my view controller, when the orientation is changed. I call my setupGUIForOrientation function in shouldAutorotateToInterfaceOrientation, like this:...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.