Created
May 21, 2010 11:00
-
-
Save mariussoutier/408705 to your computer and use it in GitHub Desktop.
This file contains 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
// 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