how to create an array with default value in scala?
I'm working on eclipse under ubuntu 12.04 with scala 2.10 and Akka 2.2.1.
val algorithm = if(args(0) > 1)()=> new A else ()=> new B // A and B
are derived from Node
class work(algorithm: ()=> Node, num: Int){
val a = new Array[Node](num)(algorithm) // here I wanna create an
array with num slots
// and objects of A or B in it
}
I read this post Default value for generic data structure, it does not
work. Eclipse reports
"type mismatch; found: ()=>Node required: Int".
I have no idea how to fix it. Thanks!
No comments:
Post a Comment