beepdog
11/07/2018, 7:20 PMbeepdog
11/07/2018, 7:22 PMsealed class Message {
abstract val id: Long
abstract val type: String
abstract val channel: String
}
data class Typing(override val id: Long, override val channel: String) : Message() {
override val type = "typing"
}
That'll do okay, it's not as clean as I'd like, but it's good enoughzkeme
11/07/2018, 7:31 PMzkeme
11/07/2018, 7:33 PMfun <T, C : Any> Iterable<T>.convert(predicate: (T) -> C): List<C>
zkeme
11/07/2018, 7:33 PMval list = ArrayList<String>()
list.convert {
}
zkeme
11/07/2018, 7:34 PMagrosner
11/07/2018, 7:34 PMUnit
is subtype of Any
zkeme
11/07/2018, 7:35 PMagrosner
11/07/2018, 7:38 PMShawn
11/07/2018, 7:39 PM.convert()
hereShawn
11/07/2018, 7:39 PM.map()
, which has the same “problem”Casey Brooks
11/07/2018, 7:41 PMAny
, and Unit
is an instance of Any
. Unit
isn’t quite the same as Java’s void
, it actually is an object, so the implicitly returned Unit
object can also be cast to Any
. You’ll need to set up some kind of base class or interface that your predicate requires other than Any
. Also, the naming might be a bit confusing, as a “predicate” is usually a function which returns a Boolean
zkeme
11/07/2018, 7:42 PMzkeme
11/07/2018, 7:43 PMkarelpeeters
11/07/2018, 8:06 PMShawn
11/07/2018, 8:06 PMShawn
11/07/2018, 8:07 PMkarelpeeters
11/07/2018, 8:08 PMcallsInPlace(block, InvocationKind.EXACTLY_ONCE)
a bit too literally.karelpeeters
11/07/2018, 8:09 PM1.2
.adams2
11/07/2018, 11:14 PMadams2
11/07/2018, 11:15 PMadams2
11/07/2018, 11:15 PMkarelpeeters
11/07/2018, 11:16 PMjw
11/07/2018, 11:18 PMvkuznetsov
11/08/2018, 3:24 PMarekolek
11/08/2018, 3:26 PMmain
with no arguments?arekolek
11/08/2018, 3:26 PMvkuznetsov
11/08/2018, 3:27 PMvkuznetsov
11/08/2018, 3:27 PMhudsonb
11/08/2018, 3:28 PM