I created a method with a default value for its ar...
# announcements
d
I created a method with a default value for its argument:
Copy code
fun foo(bar: String = "foobar") {
        Timber.i("bar: %s", bar)
    }
Why I can’t use the default value from Java? Kotlin generates this method:
Copy code
public final void foo(@NotNull String bar)
    {
        Intrinsics.checkParameterIsNotNull(bar, "bar");Timber.i("bar: %s", new Object[] {bar });
    }
but why not this:
Copy code
public final void foo(){
        foo("foobar");
    }
    
    public final void foo(@NotNull String bar)
    {
        Intrinsics.checkParameterIsNotNull(bar, "bar");Timber.i("bar: %s", new Object[] {bar });
    }