I’m new to Scala and Scala.js and I’m struggling with some basic concepts, even before I actually start to think about application logic… And I must say I DO want to learn this, because I see so much potential in this language!
The main problems I run into are due to my lack of understanding of SBT dependencies and
import statements. As an example, I cloned a starter project from scala-js-example-app, which includes the following
// Turn this project into a Scala.js project by importing these settings enablePlugins(ScalaJSPlugin, WorkbenchPlugin) scalaVersion := "2.11.8" name := "Example" version := "0.1-SNAPSHOT" libraryDependencies ++= Seq( "org.scala-js" %%% "scalajs-dom" % "0.9.1", "com.lihaoyi" %%% "scalatags" % "0.6.1", "com.lihaoyi" %%% "scalarx" % "0.3.2", )
First, why do I sometimes see
%% or even
%%% in the dependencies definition? Why one, two or three signs? What do they mean?
Second, is there a way to update all package dependencies, similar to
npm update in Node.js? I included a package that somehow changed my Scala version:
[warn] Scala version was updated by one of library dependencies:
So I tried to change it manually in the
build.sbt file, but that caused the application to crash.
Import from dependency
Finally, how am I supposed to know what the
import statement is supposed to look like for a specific managed dependency? As an example, I included
"com.mediamath" %%% "scala-json" % "1.0" as a dependency, but I must
import json._ in my
.scala file. If it weren’t for the documentation, how could’ve I guessed it?
Thanks helping a green Scala programmer!