Skip to content

Instantly share code, notes, and snippets.

@mariussoutier
Created May 21, 2010 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariussoutier/408705 to your computer and use it in GitHub Desktop.
Save mariussoutier/408705 to your computer and use it in GitHub Desktop.
// Scala - you gotta love it.
class MPSList[T](val list: List[T]) {
def removeByIndex(index: Int): MPSList[T] = {
new MPSList[T](list.remove(list.indexOf(_) == index))
}
}
object MPSList {
implicit def mpsListToScalaList[T](list: List[T]) = new MPSList[T](list)
implicit def scalaListToMPSList[T](list: MPSList[T]) = list.list
}
import MPSList._
var fruits = List[String]("Apple", "Banana", "Carrot")
fruits = fruits.removeByIndex(0)
println(fruits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment