I'm building my code with Kotlin.
I've stumbled upon a problem using Lambda in Kotlin with the following:
Java code:
((UndertowEmbeddedServletContainerFactory) container)
.addBuilderCustomizers(builder ->
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
Using common interface instantiation
((UndertowEmbeddedServletContainerFactory) container)
.addBuilderCustomizers(new UndertowBuilderCustomizer() {
@Override
public void customize(Builder builder) {
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true);
}
});
My code in Kotlin
val c: UndertowEmbeddedServletContainerFactory = (container as UndertowEmbeddedServletContainerFactory)
// Calling the Lambda
c.addBuilderCustomizers{ (b: Builder) -> b.setServerOption(UndertowOptions.ENABLE_HTTP2, true) }
It's giving me a syntax error:
Multiple markers at this line - Passing value as a vararg is only allowed inside a parenthesized argument list - Cannot infer a type for this parameter. Please specify it explicitly.
What might be the correct syntax to this?