Created
January 11, 2012 13:44
-
-
Save machisuji/1594711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def seqPlusHead[S <: Seq[T], T](seq: S): (S, T) = seq -> seq.head | |
| seqPlusHead[List[String], String](List("Hallo", "Welt")) | |
| // -> (List[String], String) = (List(Hallo, Welt),Hallo) | |
| def onlySeqPlusHead[Seq[T], T](seq: Seq[T]) = seqPlusHead[Seq[T], T](seq) | |
| // error: type arguments [Seq[T],T] do not conform to method seqPlusHead's type parameter bounds [S <: Seq[T],T] | |
| // def onlySeqPlusHead[Seq[T], T](seq: Seq[T]) = seqPlusHead[Seq[T], T](seq) | |
| onlySeqPlusHead[Seq[String], String](Seq(1, 2, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment