E07280: access modifier is not needed here - methods are 'public' by default
What went wrong
You've explicitly marked something 'public' when it's already public by default. EK9 methods are public by default.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 94 (How do I implement a constructor in EK9?)
[EK9 VISIBILITY DEFAULTS]
- Methods: public (default)
- Properties: public (default)
- Use 'private' or 'protected' only when needed
How to fix it
- Remove 'public' keyword - it's the default
Common causes
- Habit from other languages (Java requires explicit public)
- Being overly explicit
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07280: access modifier is not needed here - methods are 'public' by default
#!ek9 defines module error.e07280.bad defines class Greeter //Methods are public unless marked otherwise public greet() <- rtn as String: "hello"
Fixed: Remove 'public': it is the default
#!ek9 defines module error.e07280.good defines class Greeter //Public, with no modifier greet() <- rtn as String: salutation() //A modifier is written only to narrow access private salutation() <- rtn as String: "hello"
Questions and answers
These Q&A entries show E07280 and its fix: