Skip to content

Instantly share code, notes, and snippets.

@machisuji
Created January 11, 2012 13:44
Show Gist options
  • Select an option

  • Save machisuji/1594711 to your computer and use it in GitHub Desktop.

Select an option

Save machisuji/1594711 to your computer and use it in GitHub Desktop.
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