qwert_ukg
03/15/2018, 5:56 AMaltavir
03/15/2018, 7:52 AMMatthias Schuster
03/15/2018, 10:07 AMrobstoll
03/15/2018, 12:45 PMjkbbwr
03/15/2018, 2:47 PMfun Int.format(format: String): String {
return String.format(format, this)
}
robstoll
03/15/2018, 4:26 PMnfrankel
03/15/2018, 10:22 PMgenerateSequence(x) { it }
krtko
03/16/2018, 12:05 AMjurajsolarml
03/16/2018, 10:29 AMelect
03/16/2018, 10:57 AMVec3t<Number>
implemented as Float
, Int
, etc..
Of course methods differing only for a different type (i.e: dot(v: Vec3t<Number>)
and dot(v: Vec3t<Float>)
) have the same signature, but if I try to call:
val vert = Vec3() // Vert3 : Vec3t<Float>
vert.dot(fromTo) // error, none of the following functions can be called. Note that dot is dot(v: Vec3t<Number>)
I have to either change dot
to dot(v: Vec3t<Float>)
or create a new set of interfaces, where I have Vec3tNumber
and Vec3tFloat
and so on..
What do you think?elect
03/16/2018, 11:12 AMVec3t<out Number>
adev_one
03/16/2018, 11:18 AMndv
03/16/2018, 2:41 PM$ -> $
- any standard library capable of doing this or do I need to build a map myself? Thanks!kartikpatodi
03/16/2018, 3:43 PMdasz
03/16/2018, 5:28 PMopen class Human()
class Men:Human()
class Women:Human()
val humanNation = asList(Women(), Man())
val womenForMe = humanNation.firstOrNull{ it is Women} as Women?
any shorter form?
thank you @agrosner for the help the solution is
inline fun <reified K:T, T> List<T>.firstOrNull(): K? = firstOrNull { it is K} as K?
usage
val womenForMe : Women = humanNation.firstOrNull()
stephan_marshay
03/16/2018, 5:36 PMhumanNation.firstOrNull {...}
?ursus
03/16/2018, 6:18 PMursus
03/16/2018, 6:26 PMpoohbar
03/16/2018, 6:43 PMpoohbar
03/16/2018, 11:36 PMpoohbar
03/16/2018, 11:48 PMnish
03/17/2018, 5:05 PMl
? because it looks like floats do with f
.cedric
03/17/2018, 6:16 PMShakeib
03/18/2018, 7:44 AMczuckie
03/19/2018, 8:05 AMkarelpeeters
03/19/2018, 8:46 AMspand
03/19/2018, 10:20 AMrrader
03/19/2018, 10:33 AMhho
03/19/2018, 10:36 AM?
after `String`… 😉altavir
03/19/2018, 10:37 AMlateinit var
. Though I do not know.how it interacts with the framework.altavir
03/19/2018, 10:37 AMlateinit var
. Though I do not know.how it interacts with the framework.rrader
03/19/2018, 10:41 AMaltavir
03/19/2018, 10:43 AMrrader
03/19/2018, 10:45 AMaltavir
03/19/2018, 10:48 AMrrader
03/19/2018, 10:50 AMEvgeniy Zaharov
03/19/2018, 10:52 AMrrader
03/19/2018, 10:55 AMaltavir
03/19/2018, 10:55 AMrrader
03/19/2018, 10:56 AMaltavir
03/19/2018, 11:00 AMrrader
03/19/2018, 11:01 AM!!
, so yes, it will be our choiseAndreas Sinz
03/19/2018, 12:39 PMString
to be null
, then you lose all of the compile-time guarantees. IMO it sounds like "Hey, lets fix the symptoms"rrader
03/19/2018, 1:36 PMAndreas Sinz
03/19/2018, 1:37 PMEvgeniy Zaharov
03/19/2018, 1:42 PMnullable
, and on second choose as needed. With this you will only needed to add mapping from one dto object, to second. But it’s possible to do it with reflection (like ModelMapper library do)rrader
03/19/2018, 1:57 PM-Xno-param-assertions
option, why not restrict this by annotation?Andreas Sinz
03/19/2018, 2:07 PMlateinit
), but you can still create a yt-issue and see what the devs sayEvgeniy Zaharov
03/19/2018, 2:15 PM-Xno-param-assertions
is a very bad solution, you will disable all runtime checks. So you will lose early failing on errors.rrader
03/19/2018, 2:16 PMAndreas Sinz
03/19/2018, 2:46 PMrrader
03/19/2018, 3:15 PM