Hexa
11/10/2018, 5:53 PMfun <A> List<A>.k(): ListK<A> = ListK(this)
Shawn
11/10/2018, 5:54 PMHullaballoonatic
11/10/2018, 7:31 PMHullaballoonatic
11/10/2018, 7:32 PMHullaballoonatic
11/10/2018, 7:33 PMHullaballoonatic
11/10/2018, 7:34 PMHullaballoonatic
11/10/2018, 7:36 PMval a = 3
val b = 0.1f
val c = 0.2f
println(a == (b + c) * 10)
false
?karelpeeters
11/10/2018, 7:37 PM3/10
is supposed to be an int, right?Hullaballoonatic
11/10/2018, 7:37 PMkarelpeeters
11/10/2018, 7:37 PM==
there's a deeper issue because that actually calls the .equals()
function.Hullaballoonatic
11/10/2018, 7:37 PMHullaballoonatic
11/10/2018, 7:38 PM0.1 + 0.2 != 0.3
Hullaballoonatic
11/10/2018, 7:39 PMkarelpeeters
11/10/2018, 7:39 PM3 + .3
doesn't compile or do you actually want 3 / 2 == 1.5
?jdemeulenaere
11/11/2018, 7:20 PM@Language("JAVA")
or // language=JAVA
for Kotlinkarelpeeters
11/11/2018, 7:43 PM@Language("kotlin")
karelpeeters
11/11/2018, 7:43 PMAlt+Enter
on a string literal, Inject Language/Reference
, search what you want.karelpeeters
11/11/2018, 7:44 PMAlt+Enter
again for the annotation.alexcouch
11/11/2018, 10:26 PMcndkhuong
11/12/2018, 6:51 AMAPXEOLOG
11/12/2018, 2:33 PMclass Vector2<T : Number>(val x: T, val y: T) {
operator fun plus(vector2: Vector2<Number>): Vector2<T> {
return Vector2(x + vector2.x, y + vector2.y) // Doesn't compile
}
}
fun main(args: Array<String>) {
Vector2(1, 1) + Vector2(2, 2) // Int
Vector2(1.0, 1.0) + Vector2(2.0, 2.0) // Double
Vector2(1, 1) + Vector2(2.0, 2.0) // Ideally second Vector2 type should be casted toInt() here
}
But it'm not sure how to do itmp
11/12/2018, 2:36 PMmp
11/12/2018, 2:37 PMFrom
interface and implement From<Double>
, From<Float>
, ... for Int
and then something like T.from(vector2.x)
could work)mp
11/12/2018, 2:39 PMmp
11/12/2018, 2:40 PMmap
member function that maps both members to make it easy to make a Vector2<Int>
from a Vector2<Double>
, etc, and then you can add
without type issues.APXEOLOG
11/12/2018, 2:42 PMMarc Knaup
11/12/2018, 4:53 PMClassCastException
with inline class
in a generic context and quickly wanted to check first if there is a new Kotlin version which may have fixed it 😄user
11/12/2018, 5:52 PMJavier
11/12/2018, 8:18 PMhttps://i.imgur.com/LgyKyDj.png▾
jw
11/12/2018, 8:27 PM