sikri
06/26/2020, 8:44 AMcoerceAtLeast has more priority then -? -2.coerceAtLeast(0) == -2Michael de Kaste
06/26/2020, 8:47 AMval x = -string.length make sense?
functions and vals always have precedence over operatorssikri
06/26/2020, 8:47 AM- is not an operator, -2 is a signed intMichael de Kaste
06/26/2020, 8:49 AM- is simply seen as a negating operator, not part of the actual number.bezrukov
06/26/2020, 8:58 AMcontrol and highlight - . It will navigate you to unaryMinus even for val x = -2. You can use (-2).coerceAtLeast(0) == 0sikri
06/26/2020, 9:09 AMMichael de Kaste
06/26/2020, 9:12 AM- does apply directly to the proceeding token shuffles up the grammar and compiler significantly.sikri
06/26/2020, 9:12 AMBIPUSH -2
val b = -2.coerceAtLeast(0) looks like
INVOKESTATIC kotlin/ranges/RangesKt.coerceAtLeast (II)I
INEGsikri
06/26/2020, 9:14 AMelse if combination, as it shows how nice to have mostly returning expressionsMichael de Kaste
06/26/2020, 9:15 AMsikri
06/26/2020, 9:30 AM2.0, 2.someFunction() ?
Will this dot operator and minus sign be analyzed differently by parser and why not?
I would be glad to here just your two cents in order to google it myself
btw, maybe you know where does it lie in kotlin sources?bezrukov
06/26/2020, 9:41 AMsikri
06/26/2020, 9:43 AMbezrukov
06/26/2020, 9:44 AMis there any major difference betweenyes, there is a major difference here -,2.0?2.someFunction()
2.someFunction is decimal literal . identifier
(identifier must start with letter and underscore) while
2.0 is decimal literal . decimal literalbezrukov
06/26/2020, 9:45 AM4.2.3. Decimal Literals A decimal literal is a sequence of one or more ASCII decimal digits, followed by an optional L (LATIN CAPITAL LETTER L, U+004C). A literal without a suffix represents a constant value of type Int (TODO: it is more complicated). A literal with suffix L represents a constant value of type Long. A decimal literal represents a constant value that results from interpreting the literal in decimal notation. The value of a literal must lie within the range of its type. [Note: Decimal literals always represent non-negative integers. For example, an expression -5 is the unary operator minus applied to an operand that is a decimal literal 5, rather than a single decimal literal. End Note]
sikri
06/26/2020, 9:54 AM