Switch emulation is too verbose compared to other languages #1237
mikhail-putilov
started this conversation in
Ideas
Replies: 1 comment
-
|
Ah, I figured out that I can compose const local function quoteIfNeeded(s: Any) =
if (s is String) "\"" + s.toString().replaceAll("\"", "\\\"") + "\""
else if (s is Boolean) s.toString()
else if (s is Code) s.toString()
else throw ("Not supported") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I have been using Pkl for generating HCL in my project. I think Pkl does its job quite well, thanks!
However, I found myself writing the following snippet in order to emulate basic switch from Java:
I find it too complicated and unusual for the others to understand. I think basic Java switch expression does the job much better than Pkl in this example. Especially considering that Pkl supports algebraic sum types, and it is cumbersome to write code that consumes the sum types (example is above).
Do you think this is something Pkl considers in its roadmap?
Beta Was this translation helpful? Give feedback.
All reactions