I am currently learning Scala and found this awesome framework called Squants that does all sorts of cool things like conversions. The problem is: I have no idea how to use it.
I come from a background of ruby gems and node packages, so I expected Scala to have a similar aspect to it.
The documentation I found didn't help much so I started searching different terms. I found this Stack Overflow question which addressed the issue with something called "sbt". I already know how to compile files with scalac
and run them with scala
, so I was a bit confused by what sbt
was until I did some research. I tried to follow the instructions and replace the libraryDependencies
with "com.squants" %% "squants" % "0.4.2"
, but that just threw a ton of errors in the sbt console. Ultimately, I want the package working with my code, not in a console.
I then found the framework on a website called Sonatype. I downloaded a jar file from this website but am not sure how to use jar files in Scala (if possible?). Searching for this revealed some not-so-beginner-friendly results.
For reference, this is my scala file that I am using to test the package:
import com.squants._
object HelloSquants {
def main(args: Array[String]): Unit = {
val x: Power = Kilowatts(12)
val y: Power = Megawatts(0.023)
val sum = x + y
println(x + " plus " + y + " equals " + sum)
}
}
What is the proper way to get this package working in Scala?