Last active
December 22, 2015 23:29
-
-
Save debasishg/6547227 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
| Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_51). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> case class Foo(i: Int) | |
| defined class Foo | |
| scala> Vector(Foo(1), Foo(2), Foo(3)) | |
| res0: scala.collection.immutable.Vector[Foo] = Vector(Foo(1), Foo(2), Foo(3)) | |
| scala> res0 patch (from=-1, patch=Nil, replaced=1) // what's going on here ? from is a valid argument name | |
| <console>:11: error: not found: value from | |
| res0 patch (from=-1, patch=Nil, replaced=1) | |
| ^ | |
| // why does it delete the first element ? Is this expected ? | |
| // this behavior makes it difficult to use this method in combination with | |
| // indexWhere .. always need to have a check with "if" to see if it's a valid index | |
| scala> res0 patch (-1, Nil, 1) | |
| res2: scala.collection.immutable.Vector[Foo] = Vector(Foo(2), Foo(3)) | |
| scala> res0 patch (from=0, patch=Nil, replaced=1) // this is ok | |
| res4: scala.collection.immutable.Vector[Foo] = Vector(Foo(2), Foo(3)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should work as expected
also