Thank you for your reply.
Q: "Hey guys, guess what -1.plus(2) will be in Kotlin?"
A: “(Since you asked me deliberately, perhaps it’s not 1) Um… -3?”
It’s different when you read about it.
“Why does these tests got failed !
-2.next() shouldBe -1?!”
I wrote extension functions for
Float. When I wrote some tests, I found this problem.
-1.plus(2) is just a simple example to emphasize how funny this problem is.
I wrote something like
-1.atLeast(0) shouldBe 0 //equals to Math.max(num,atLeast)
or some BDD assertions:
But when take these functions in the project it will be
vocabulary.atLeast(0). No confusion at all !
Yole said what is done cannot be undone， so I’m not confused about it at all now.
Finally I realize there’s no perfect languages, it’s my fault to always think that the only constant in the world is change.
I still use Kotlin everyday and discover a lot of fun about Kotlin,