Let’s take a look at some examples:
Example1:
object Tests extends App {
println(Rating("PG",13))
println(Rating.apply("PG",13)) //This is equivalent, so you don't need to explicitly call apply
}
Syntactic sugar is just a way that we re-write our code to a simple and human-readable form, it does not change any function of a method.
IntelliJ IDEA offers a Desugar Scala Code function, you can use that to discover what this syntactic sugar actually stands for.
Here is an example:
def lift[T1,T2](f: T1 => T2):Try[T1]=>Try[T2] = _ map f