val scalaToolsSnapshots = "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"
val specs = "org.scala-tools.testing" % "specs_2.9.0-1" % "1.6.8" % "test"
What does this mean?
Scala string is an immutable object that means the object cannot be modified. Each element of a string is associated with an index number. The first character is associated with the number 0, the second with the number 1, etc. Class java.
Creating a Stringvar greeting = "Hello world!"; or var greeting:String = "Hello world!"; Whenever compiler encounters a string literal in the code, it creates a String object with its value, in this case, “Hello world!”.
Get length of the string So, a length() method is the accessor method in Scala, which is used to find the length of the given string. Or in other words, length() method returns the number of characters that are present in the string object. Syntax: var len1 = str1.
That is sbt (simple build tool) DSL that defines managed dependencies of project.
Format is quite simular to maven: first line says where to find repository, second line defines dependency like "groupId" % "artifactId" % "version" % "scope"
For details look at the sbt wiki page (section Managed Dependencies)
you can also simplify this declaration using the following :
scalaVersion := "2.9.0-1"
scalaToolsSnapshots := "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"
specs := "org.scala-tools.testing" %% "specs" % "1.6.8" % "test"
%%
will specify to sbt to use a specs version that is binary compatible with your project scala version.
You should consider using it especially if you plan to upgrade scala version or if you plan to publish a lib against multiple scala versions.
under the hood, first String is implicitly converted to a GroupID
with %%
method that convert next String to a GroupArtifactId
, the following %
creates a ModuleID
and the last %
adds a scope to the ModuleID
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With