fromMedium
1 week agoScala 3 makes reserved word "new" optional
As a toy example, consider package org.example.graphicsobject WrappedColor { def apply(r: Int, g: Int, b: Int): WrappedColor = new WrappedColor(r, g, b)}import java.awt.Colorclass WrappedColor(r: Int, g: Int, b: Int) { val color = new Color(r, g, b)} Then we can write things like val wrapC = WrappedColor(128, 0, 255) Okay, seems like a lot of effort just to not have to write " new." But Scala programmers with a lot more sophistication than myself have been wanting this effort.
Java