Jacob
10/19/2020, 9:00 PM.not() and when I should use good old ! https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/not.htmlnanodeath
10/19/2020, 9:07 PMnot()Jacob
10/19/2020, 9:08 PMtseisel
10/19/2020, 9:18 PM!condition is used in most programming languages (or at least in most of those I know). Because it is more familiar to non-Kotlin developers, I think i'ts more readable than condition.not(), especially in long conditions.
AFAIK the Kotlin compiler may not fully optimize the .not() function call in some cases, compared to when using !nanodeath
10/19/2020, 9:22 PM! and .not() to be bytecode-equivalent since .not() is just an operator function, btw.nanodeath
10/19/2020, 9:22 PMEven André Fiskvik
10/19/2020, 9:22 PMnanodeath
10/19/2020, 9:24 PMJacob
10/19/2020, 9:36 PMSon
10/19/2020, 9:36 PMfun test(): Boolean = true
fun main () { test().not() }
// decompiled
public static final boolean test() { return true;}
public static final void main() { if (!test()) {} }Son
10/19/2020, 9:38 PMSon
10/19/2020, 9:40 PMnanodeath
10/19/2020, 10:08 PM! operator is implementednanodeath
10/19/2020, 10:09 PMplus doesn't mean you're supposed to call it by that namenanodeath
10/19/2020, 10:09 PMephemient
10/20/2020, 12:58 AMconst val, otherwise it's not constant and can't be inlined at compile time.elizarov
10/20/2020, 8:00 AMSomeone on my team is using it. A lot. What should I tell him to discourage him?"You must unlearn what you have learned." (c) Yoda
Joris PZ
10/20/2020, 8:55 AMtodd.ginsberg
10/21/2020, 1:33 PM