well friends, I seem to remember one of the promis...
# announcements
g
well friends, I seem to remember one of the promises of kotlin was "no more (java-style) boiler-plate." Well I wanted to wrap Win32/Kernel32 to make using it from java a little more idiomatic. What I came up with was this:
Copy code
//usage:
Kernel32::SetEnvironmentVariable.invokeForSuccessOrThrowLastError("EMPOWER_LGO_TRACE", "TRUE")
The key here is that I wanted to convert from Win32's C-compatible
GetLastError()
into java exceptions. To get this I needed a good whack of boiler-plate. see attached kt. Am I missing something? Would arrow let me do something more clever here? I think at its roots the kotlin type signatures for functions do not let me write a single type that captures different arity. tl;dr anybody know how i can write the boiler-plate in KotlinExtensions.kt more compactly?