Skip to content

Instantly share code, notes, and snippets.

@debasishg
Last active December 22, 2015 23:29
Show Gist options
  • Select an option

  • Save debasishg/6547227 to your computer and use it in GitHub Desktop.

Select an option

Save debasishg/6547227 to your computer and use it in GitHub Desktop.
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))
@gouthamvel

Copy link
Copy Markdown

should work as expected

res0 patch (from=(-1), patch=Nil, replaced=1) 

also

res0 patch (from= -1, patch=Nil, replaced=1) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment