Re:Show HN: I finished v5 of a JVM framework I've spent spen...
by pkulak on Monday October 03, 2022 @11:34AM
(#33068988)
I'm pretty sure the "Hello Javalin World" Kotlin example won't compile, just FYI.
[ Parent
| on HN ]
Re:Show HN: I finished v5 of a JVM framework I've spent spen...
by tipsee on Monday October 03, 2022 @11:37AM
(#33069024)
Seems to compile fine here, what's the issue?
Edit: I was looking at the wrong snippet, the offending snippet has been fixed.
Re:Show HN: I finished v5 of a JVM framework I've spent spen...
by gavinray on Monday October 03, 2022 @12:10PM
(#33069474)
Probably not used to seeing lambdas inside of parens:
.get("/", ctx -> ctx.result("Hello World"))
Could also be written as .get("/") { ctx -> ctx.result("Hello World") }
The second form seems much more common in Kotlin.
Re:Show HN: I finished v5 of a JVM framework I've spent spen...
by tipsee on Monday October 03, 2022 @12:52PM
(#33070156)
Yeah, no, he was 100% correct, I was just looking at the wrong snippet.
It's been fixed now :)
Re:Show HN: I finished v5 of a JVM framework I've spent spen...
by pkulak on Monday October 03, 2022 @12:33PM
(#33069835)
Huh, I wonder what's different with my setup. I would need to put curly braces around that closure before it would compile, i.e:
.get("/", { ctx -> ctx.result("Hello World") })
Closures defined only by the arrow are a Java thing... or so I thought. :D
Re:Show HN: I finished v5 of a JVM framework I've spent spen...
by tipsee on Monday October 03, 2022 @12:45PM
(#33070038)
> Closures defined only by the arrow are a Java thing... or so I thought. :D
In fairness, I think you did copy the Java version. There's a little switch in the code boxes where you can toggle the language, if you switch to Kotlin you get the version with trailing closures :)
Edit: I'm an idiot, I see the snippet you mean now. It's been updated now, give it a minute.