"As I write this article, Scastie, the official online read-eval-print-loop (REPL) for Scala, does not show warnings. This is not necessarily a bad thing. Just be prepared to have to address warnings when you copy from Scastie into an integrated development environment (IDE) like IntelliJ IDEA. Consider the following toy example: import java.time.{DayOfWeek, LocalDate}def previous(origin: LocalDate, day: DayOfWeek): LocalDate = { val originOrd = origin.getDayOfWeek.ordinal val targetOrd = day.ordinal val diff = originOrd - targetOrd; var adjust = if (diff <= 0) 7 else 0 val daysToSubtract = diff + adjust origin.minusDays(daysToSubtract)}val today = LocalDate.now()val prevFriday = previous(today, DayOfWeek.FRIDAY)println(s"Previous Friday is ${prevFriday.toString()}")"
"I have a slightly different version in a Scastie snippet. But if you copy either from here or from Scastie into IntelliJ IDEA, you should see at least two warnings or weak warnings come up: The semicolon on line 6 is unnecessary. Of course if there are any syntax errors in what you put into Scastie, it will show those as soon as you try to run. I suppose it would be nice if it also showed warnings. Even without that feature, Scastie is nevertheless a valuable tool for learning programming in Scala."
Scastie, the official online read-eval-print-loop (REPL) for Scala, does not show warnings. A provided toy example uses java.time.LocalDate and DayOfWeek to compute a previous weekday via ordinal arithmetic. Copying the code into an IDE such as IntelliJ IDEA will surface warnings or weak warnings, for example an unnecessary semicolon on a specific line. Scastie will still report syntax errors when attempting to run code. The absence of displayed warnings does not remove Scastie’s usefulness as a learning tool for programming in Scala.
Read at Medium
Unable to calculate read time
Collection
[
|
...
]