karelpeeters
08/18/2017, 10:31 PMjtonic
08/18/2017, 10:32 PMjtonic
08/18/2017, 10:32 PMkarelpeeters
08/18/2017, 10:32 PMlateinit var
in Java? I assume it wasn't any safer than just a default value for your Int.jtonic
08/18/2017, 10:32 PMjtonic
08/18/2017, 10:33 PMjtonic
08/18/2017, 10:33 PMjtonic
08/18/2017, 10:36 PMjtonic
08/18/2017, 10:36 PMkarelpeeters
08/18/2017, 10:39 PMjtonic
08/18/2017, 10:48 PMjtonic
08/18/2017, 10:49 PMkarelpeeters
08/18/2017, 10:51 PMjtonic
08/18/2017, 10:52 PMersin_ertan
08/19/2017, 3:23 AMfun DieRoll.cheatRoll():Int = roll(min = max -1)
// roll is defined as fun roll(min: Int = 1, max: Int = 6): Int = (min..max).rand()
leonardootto
08/19/2017, 4:46 AMroopehakulinen
08/19/2017, 4:24 PMpakoito
08/19/2017, 4:38 PMpakoito
08/19/2017, 4:40 PMThing<out A>
in Kotlin, and would like to make another interface in Java so that I can write Thing<out A>: JThing<A>()
. How would you write JThing in Java in a way that retains the information about A.diesieben07
08/19/2017, 4:45 PMJThing<? extends A>
everywhere you use it.pakoito
08/19/2017, 4:52 PMdarktilrisen
08/19/2017, 5:35 PMval x: Number = 1 //There is no specific reason here why you would like to do this, but it's the
val y: Number = 1 + x //easiest example I could come up with.
I know java doesn't do this either and there probably is probably a good reason for it. What am I missing here?karelpeeters
08/19/2017, 5:54 PMNumber
? I don't know anything about it. It's also not possible to implement such a plus method, what about BigInt(100000000000000000)+ Fraction(1,3)
? How would that work?karelpeeters
08/19/2017, 5:55 PMkarelpeeters
08/19/2017, 7:01 PMNumber
interface is ever useful at all, it only "helps" with implementing the to***
methods correctly.darktilrisen
08/19/2017, 7:48 PMfun <T : Number, C : Number, K : Number> List<T>.add(other: List<C>): List<K> =
if (size != other.size) throw IllegalStateException("the size of both lists should be equal.")
else mapIndexed { index: Int, value: T -> value.plus<C, K>(other[index]) }
But even with the abstract fuctions it wouldn't work 😞 my badraulraja
08/19/2017, 8:39 PMNumeric
representation similar in concept to what you were asking about https://github.com/scala/scala/blob/v2.12.3/src/library/scala/math/Numeric.scala#L1 Something similar may be doable in Kotlin, though Numeric
is a typeclass, with extensions you may be able to add it to Number
or their subtypes in those that where it makes sense and leaving the problematic ones out.darktilrisen
08/19/2017, 8:41 PMdarktilrisen
08/19/2017, 8:43 PM