Creating classes that can be instantiated with single or multiple elements as constructor's argument
Posted
by Jeriho
on Stack Overflow
See other posts from Stack Overflow
or by Jeriho
Published on 2010-06-01T13:14:52Z
Indexed on
2010/06/02
12:34 UTC
Read the original article
Hit count: 213
scala
|collections
I want to have class that can be instantiated with list, array, seq, set, stack, queue etc. In my opinion
class A
class B(elems:A*)
should handle such stuff.
This is my solution:
class A
class B(elems:Iterable[A]){
def this(elem:A) = this(Seq(elem))
}
Can you suggest any improvements?
© Stack Overflow or respective owner