Je traversais le merveilleux livre Programming in Scala quand je suis tombé sur un morceau de code qui vient n'a pas de sens pour moi:Scala syntaxe de point (ou son absence)
def above(that: Element): Element = {
val this1 = this widen that.width
val that1 = that widen this.width
elem(this1.contents ++ that1.contents)
}
Remarque la ligne 2 et 3:
val this1 = this widen that.width
Il semble que je devrais pouvoir le remplacer par:
val this1 = this.widen that.width
Cependant, lorsque je tente de compiler ce changement, il donne l'erreur suivante:
error: ';' expected but '.' found.
val this1 = this.widen that.width ^
Pourquoi cette syntaxe inacceptable?
Copies possibles: http://stackoverflow.com/questions/1181533/what-are-the-precise-rules-for-when-you-omit-parenthesis-dots-braces-fu et http: // stackoverflow.com/questions/1006967/scala-which-characters-can-i-omit –