yo estaba pasando por el maravilloso libro Programming in Scala cuando me encontré con un pedazo de código que simplemente no tiene sentido para mí:sintaxis con punto Scala (o falta de ella)
def above(that: Element): Element = {
val this1 = this widen that.width
val that1 = that widen this.width
elem(this1.contents ++ that1.contents)
}
Nota línea 2 y 3:
val this1 = this widen that.width
parece como si tuviera que ser capaz de reemplazar esto con:
val this1 = this.widen that.width
Sin embargo, cuando intento compilar este cambio, se da el siguiente error:
error: ';' expected but '.' found.
val this1 = this.widen that.width ^
¿Por qué es esta sintaxis inaceptable?
Posibles duplicados: http://stackoverflow.com/questions/1181533/what-are-the-precise-rules-for-when-you-can-omit-parenthesis-dots-braces-fu and http: // stackoverflow.com/questions/1006967/scala-which-characters-can-i-omit –