diff options
author | Paul Phillips <paulp@improving.org> | 2013-08-15 15:02:18 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-08-17 08:21:43 -0700 |
commit | 44b4dcfc959d1305b96b21cc73a8e74aea865fa0 (patch) | |
tree | 8c99884e93d011974053c30a03ec30d793cb2dd3 /src/library | |
parent | de1d8c3a89e95e1b934da05453f8e1fed925c838 (diff) | |
download | scala-44b4dcfc959d1305b96b21cc73a8e74aea865fa0.tar.gz scala-44b4dcfc959d1305b96b21cc73a8e74aea865fa0.tar.bz2 scala-44b4dcfc959d1305b96b21cc73a8e74aea865fa0.zip |
Add a helper method drop to ScalaRunTime.
We should do a lot more of this - it's ridiculously difficult
and error prone to generate code of this kind involving implicits,
type inference, etc. where the same goal is trivially accomplished
by generating a method call and letting the typer work out the
details.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 77fe2eb1e1..315f56bd4e 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -12,7 +12,7 @@ package runtime import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator } import scala.collection.mutable.WrappedArray import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: } -import scala.collection.generic.{ Sorted } +import scala.collection.generic.{ Sorted, IsTraversableLike } import scala.reflect.{ ClassTag, classTag } import scala.util.control.ControlThrowable import java.lang.{ Class => jClass } @@ -48,6 +48,10 @@ object ScalaRunTime { names.toSet } + // A helper method to make my life in the pattern matcher a lot easier. + def drop[Repr](coll: Repr, num: Int)(implicit traversable: IsTraversableLike[Repr]): Repr = + traversable conversion coll drop num + /** Return the class object representing an array with element class `clazz`. */ def arrayClass(clazz: jClass[_]): jClass[_] = { |