What are the differences between ++ = and + = in sbt, say with libraryDependencies?

I am new to Scala and sbt and I can not understand what the differences are between them:

libraryDependencies ++= Seq(...)

and

libraryDependencies += ...
+4
source share
5 answers

This += depor ++= Seq(dep, dep2, dep3): "Of course, you can also use ++ = to add a list of (read: multiple) dependencies all at once . "

See collections.Seq for operators +("add item") and ++("add sequence").

+11
source

See Adding to previous values: + = and ++ = :

:= , . T in SettingKey[T] , , , .

  • += .
  • ++= .

, sourceDirectories in Compile Seq[File] .

+6

- .

-, ...=. , Java , ... , - libraryDependencies.

-, ++, +. Seq Scaladoc, . , :

  • + , .
  • ++ .

, .

  • List(1, 2, 3) ++ List(4, 5, 6) List(1, 2, 3, 4, 5, 6), ...
  • List(1, 2, 3) + List(4, 5, 6) List(List(1, 2, 3), 4, 5, 6).
+2

, , sbt.build, Scala. Scala , SBT.

, Scala:

  • += (, ArrayBuffer[T]) . - T, .
  • ++=, , , ++=. TraversableOnce[T], Scala (, Seq[T]).

, , ArrayBuffer[Int], :

val testSeq = ArrayBuffer(1, 2, 3, 4)

testSeq += 5

testSeq ArrayBuffer(1, 2, 3, 4, 5).

testSeq += Seq(5, 6, 7, 8)

testSeq ArrayBuffer(1, 2, 3, 4, 5, 6, 7, 8).

testSeq ++= 5

, ++= , . ++=, :

testSeq ++= Seq(5)

, .

+2

++ Seq Seq.

+Adds one item to the beginning Seq.

=after +and ++indicates that the left hand Seqis varand will be updated.

The documentation for Seq is here .

+1
source

All Articles