Karl Bielefeldt
object Main {
def main(args: Array[String]): Unit = {
val xs = List(-2, -1, 0, 1, 2)
val ys = List(3, 4, 5, 6, 7)
val result = for {
x <- xs
y <- ys
} yield if (x > 0) x else y
result.foreach(println)
}
}
@main def main =
val xs = List(-2, -1, 0, 1, 2)
val ys = List(3, 4, 5, 6, 7)
val result = for
x <- xs
y <- ys
yield if x > 0 then x else y
result.foreach(println)
TypeIActuallyWant with Product with Serializable
TypeIActuallyWant
-- [E007] Type Mismatch Error: Main.scala:2:23
2 | val string: String = null
| ^^^^
| Found: Null
| Required: String
-- Error: Main.scala:2:2
2 | "string" == 42
| ^^^^^^^^^^^^^^
| Values of types String and Int cannot be compared
| with == or !=
-- Error: Main.scala:6:7
6 | list combine other
| ^^^^^^^
|Alphanumeric method combine is not declared `infix`;
|it should not be used as infix operator. The operation
|can be rewritten automatically to `combine` under
| -deprecation -rewrite. Or rewrite to method syntax
|.combine(...) manually.
class MyClass(arg: Int)
// In Scala 2, this gives error: not found: value MyClass
// Works fine in Scala 3
MyClass(1)
extension (c: Circle)
def circumference: Double = c.radius * math.Pi * 2