title | type | description | num | previous-page | next-page |
---|---|---|---|---|---|
Methods |
chapter |
This section introduces methods in Scala 3. |
24 |
domain-modeling-fp |
methods-most |
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.