https://kotlinlang.org logo
Title
f

Florian

06/20/2019, 9:31 PM
This might be a dumb question but where are the method bodies for the operators functions inside Primitives.kt
k

karelpeeters

06/20/2019, 9:39 PM
As I said (https://kotlinlang.slack.com/archives/C0B8MA7FA/p1561059246214900?thread_ts=1560978823.192000&cid=C0B8MA7FA), they don't have bodies, they're compiler intrinsics. They just end up as single inlined bytecode instructions on the JVM.
f

Florian

06/20/2019, 9:42 PM
Sorry I didn't see that
that was my assumption
thanks
k

karelpeeters

06/20/2019, 9:42 PM
But now I do want to know where that code is in the compiler 😄
f

Florian

06/20/2019, 9:43 PM
do you know any examples in the stdlib that have operators functions with bodies?
k

karelpeeters

06/20/2019, 10:17 PM
Lists, BigInteger, BigDecimal, Arrays, String.
f

Florian

06/21/2019, 9:04 AM
ok thanks
No, the String class also doesn't have a body
for plus
neither does List
BigDecimal doesnt have any operator funs at all
You're right, I can't find one for strings.
f

Florian

06/21/2019, 1:24 PM
thanks
for some reason they are not like this when I open them in IntelliJ
k

karelpeeters

06/21/2019, 1:27 PM
They are for me, I just did
Ctrl+B
on the
+
in this code:
val x = arrayOf(1,2,3) + arrayOf(4,5,6)
val y = listOf(1,2,3) + listOf(4,5,6)
f

Florian

06/21/2019, 2:05 PM
yea that works
k

karelpeeters

06/21/2019, 2:05 PM
What didn't work then?
f

Florian

06/21/2019, 2:19 PM
BigInteger doesnt have this function in my source code
k

karelpeeters

06/21/2019, 2:20 PM
Where does
Ctrl+B
on
val z = BigInteger.ONE + BigInteger.ONE
get you?
f

Florian

06/21/2019, 2:28 PM
Oops, I ended up in the Java package