Scala 3 — Book

Methods

Language
Info: JavaScript is currently disabled, code tabs will still work, but preferences will not be remembered.

In Scala 2, methods can be defined inside classes, traits, objects, case classes, and case objects. But it gets better: In Scala 3 they can also be defined outside any of those constructs; we say that they are "top-level" definitions, since they are not nested in another definition. In short, methods can now be defined anywhere.

Many features of methods are demonstrated in the next section. Because main methods require a little more explanation, they’re described in the separate section that follows.

Contributors to this page:

Contents

AltStyle によって変換されたページ (->オリジナル) /