list of constructors

View: New views
1 Messages — Rating Filter:   Alert me  

list of constructors

by Andrew Gaydenko :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Hi!

I have tried to filter my intention in short code shown below. The aim is to
declare a list of (concrete, C1 and C2 here) classes' parameterless
constructors, when these classes all inherit from T1.

The question is: can 'All.def list = ...' be written more concise? Class 'All'
is intended to be outside a lib, i.e. it is user's code. 'Unit => new C1'
looks slightly bulky.


Andrew

=========================================

trait T1

trait T2[+T] {
  def list : List[Unit => T]
}

trait T3 extends T2[T1]

class C1 extends T1
class C2 extends T1

class All extends T3 {
  def list = List(Unit => new C1, Unit => new C2)
}