#language-evolution
Title
# language-evolution
h

Hullaballoonatic

11/09/2019, 8:46 PM
Copy code
``````val i = 2
-i // -2
~i // 0.5

val M = Matrix.ofRows(vectorOf(4, 7), vectorOf(2, 6))
// [ 4 7
//   2 6 ]
-M
// [ -4 -7
//   -2 -6 ]
~M
// [  0.6 -0.7
//   -0.2  0.4 ]``````
👍 1
k

karelpeeters

11/09/2019, 9:38 PM
``!``
is still free!
Or you can use
``1 /``
too.
h

Hullaballoonatic

11/09/2019, 9:39 PM
Yeah, but both operators I suggested exist in Kotlin and I like them a lot
In math
``~``
does actually mean inverse, too
k

karelpeeters

11/09/2019, 9:40 PM
``~``
doesn't exist in Kotlin yet?
h

Hullaballoonatic

11/09/2019, 9:41 PM
It doesn't, hence why I think it could
At the same time I think it'd be cool to have an overload able ~= which would mean "about equal to", but that would conflict with the obvious inverseAssign of my higher priority wish
k

karelpeeters

11/09/2019, 9:44 PM
Haha that would be great for matlab users where
``~=``
is our
``!=``
h

Hullaballoonatic

11/09/2019, 9:44 PM
Yeah, some languages like Matlab and lua use ~ as not where python uses it as inverse
e

elizarov

11/11/2019, 7:42 AM
Let’s take a look at what we already have.
``a - b``
is subtraction and
``-b``
is an additive inverse. Following this logic, because
``a / b``
denotes division, then multiplicative inverse should be denoted as
``/b``
(
``operator unaryDiv``
?).
🤔 1
👍 2
h

Hullaballoonatic

11/11/2019, 7:46 PM
that's a fantastic suggestion as well
have there ever been any plans for using
``~``
in kotlin?
k

Ky Leggiero

11/12/2019, 11:08 PM
@Hullaballoonatic probably not, for the same reasons that
``^``
and
``|``
were excluded; they'd prefer to keep bitwise operators as words to improve clarity. If you could (re-)define them yourself, I'd bet over 50% of Kotlin codebases would re-introduce these as the bitwise operators. Regardless of my feelsings on this, I don't think JetBrains wants that
3 Views