Maybe merging interface with trait could be possible in the future, but would using the "trait" keyword instead of "interface" have any negative effects in your scenario ? I only use trait where I need the added functionality, but technically it behaves just like a suped up interface afaiaao...

Cheers,
mg

On 05/01/2021 17:14, Jochen Theodorou wrote:
Hi Paul,

wouldn't it be possible to implement the default parameter now with
default methods?

On 05.01.21 05:39, Paul King wrote:
You could potentially use a trait?

trait MyTrait {
     abstract myFunction(String parameter1 = "1234")
}

class MyClass implements MyTrait {
     def myFunction(String parameter1) {
         parameter1.reverse()
     }
}

assert new MyClass().myFunction() == '4321'


On Tue, Jan 5, 2021 at 1:22 PM Saravanan Palanichamy <chava...@gmail.com
<mailto:chava...@gmail.com>> wrote:

    Hello

    Are there plans to support default parameters in interface methods

    interface MyClass {
         def myFunction(String parameter1 = "1234")
    }

    the error I get is Cannot specify default value for method parameter
    inside an interface

    regards
    Saravanan



Reply via email to