Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val scala3 = "3.1.0"
val scala3 = "3.1.2"
lazy val root = project
.in(file("."))
.settings(
Expand All @@ -16,17 +16,17 @@ lazy val root = project
// Notice how the Scala 2.13-built libraries are used. For more information:
// https://www.scala-lang.org/blog/2021/04/08/scala-3-in-sbt.html
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor-typed" % "2.6.14",
"com.typesafe.akka" %% "akka-slf4j" % "2.6.14",
"com.typesafe.akka" %% "akka-actor-typed" % "2.6.19",
"com.typesafe.akka" %% "akka-slf4j" % "2.6.19",
).map(dep => dep.cross(CrossVersion.for3Use2_13)) ++ Seq(
// Libraries that already fully support Scala 3:
"org.typelevel" %% "cats-core" % "2.6.1",
"org.typelevel" %% "cats-core" % "2.7.0",
"org.scala-lang" %% "scala3-staging" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.0.0",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1",
"ch.qos.logback" % "logback-classic" % "1.2.11",
"org.scalacheck" %% "scalacheck" % "1.15.4" % Test,
"org.scalameta" %% "munit" % "0.7.26" % Test,
"org.scalameta" %% "munit-scalacheck" % "0.7.26" % Test,
"org.scalameta" %% "munit" % "0.7.29" % Test,
"org.scalameta" %% "munit-scalacheck" % "0.7.29" % Test,
"com.eed3si9n.expecty" %% "expecty" % "0.15.4" % Test,
),

Expand Down
1 change: 1 addition & 0 deletions src/main/java/progscala3/objectsystem/JavaArrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

public class JavaArrays {
public static void main(String[] args) {
System.out.println("*** A java.lang.ArrayStoreException will be thrown: ***");
Integer[] array1 = new Integer[] {
Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
Number[] array2 = array1; // Compiles fine, but shouldn't!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ object PayrollCalculator: // <1>
(name, salary, ruleString) <- data
yield Pay(name, salary, toDeductions(ruleString))

case class BadInput(message: String, input: String)
extends RuntimeException(s"Bad input data, $message: $input")
case class BadInput(message: String, input: String, array: Array[String])
extends RuntimeException(s"""Bad input data, $message: "$input" (array = ${array.mkString("[", ",", "]")}) """)

private type Record = (String, Dollars, String) // <4>

Expand All @@ -33,13 +33,13 @@ object PayrollCalculator: // <1>
yield toRule(line)

private def toRule(line: String): Record = // <5>
line.split("""\s*,\s.*""") match
line.split("""\s*,\s*""") match
case Array(name, salary, fedTax, stateTax, insurance, retirement) =>
val ruleString = dsl.format(
fedTax.toDouble, stateTax.toDouble,
insurance.toDouble, retirement.toDouble)
(name, Dollars(salary.toDouble), ruleString)
case array => throw BadInput("expected six fields", line)
case array => throw BadInput("expected six fields", line, array)

private val parser = PayrollParser() // <6>
private def toDeductions(rule: String): Deductions =
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/progscala3/basicoop/Abstract.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class HelloService(override val name: String) // <3>

// tag::main[]
@main def HelloServiceMain(name: String, users: String*): Unit =
val hs = HelloService("hello")
val hs = HelloService(name)
for
user <- users
request = Map("user" -> user)
Expand Down