https://kotlinlang.org logo
Title
k

kevinmost

11/29/2017, 7:45 PM
Kotlin doesn't use
void
or
Void
, it uses
Unit
. You want
logic: (g: Graphics) -> Unit
j

jamie-purchase

11/29/2017, 7:47 PM
ah ok and just ignore the return content and don't worry about what Unit might be then?
cheers
s

Shawn

11/29/2017, 7:48 PM
I’m not sure what you mean by “ignore the return content”. If you type the lambda as returning
Unit
, it can’t return anything
if it returns
null
, then that’s not returning
Unit
j

jamie-purchase

11/29/2017, 7:50 PM
it's ok i'm new to Kotlin and wasn't familiar with what
Unit
is - i've caught up now
This type corresponds to the void type in Java.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html
k

kevinmost

11/29/2017, 7:51 PM
Unit
is a Kotlin object so it's a singleton, and only one exists. Kotlin implicitly does
return Unit
similar to how Java does for
void
Right, important distinction is that
null
is not of the type
Unit
.
Unit
is a non-nullable type so
null
does not fit in there
j

jamie-purchase

11/29/2017, 7:52 PM
i've abandoned my thoughts about null (that was just a Java way of explaining my question) and it's working fine with
Unit
👍 1
should have said "function that returns void" instead of null, sorry
s

Shawn

11/29/2017, 7:53 PM
no worries, just a little confusing considering void functions can’t return null either 😅
j

jamie-purchase

11/29/2017, 7:56 PM
quite right. I spend my days writing web applications in ColdFusion - a language built on the JVM but without null support - i'm allowed to say the wrong thing occasionally when I spend my spare time using proper languages, right? 😉
s

Shawn

11/29/2017, 7:57 PM
oof, that’s a name I haven’t heard in a long time haha
j

jamie-purchase

11/29/2017, 7:57 PM
haha it's either "what's that?" or "is that still alive" when you drop it
m

madorb

11/29/2017, 8:13 PM
it had literally no idea coldfusion runs on the jvm.
i guess though, last time i knew someoe actively using it was 1999 and it wasn’ ton the JVM at that point 😄
j

jamie-purchase

11/29/2017, 8:59 PM
well i've only been using version 10 and upwards (released on May 15, 2012 according to wikipedia) it's cool being able to do things like
var buffer = createObject("java", "java.lang.StringBuffer");
to dip into java classes and use them in cfml the language is still miserably behind most modern developments but thanks to the lucee.org (open source cfml engine) and https://www.ortussolutions.com/products/commandbox (CLI and package management) we are slowly getting there there is support for lambas but buggy, static modifiers and generics are still nonexistent
you can load external JARs as well so it's entirely possible to utilise methods/classes written in Scala/Clojure/Kotlin and pass them around like cf objects, it's all JVM at the end of the day
but enough of that i'm here to get away from CF haha @madorb