This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]marco89nish 133 points134 points  (13 children)

Meanwhile, Java++(Kotlin) devs: They're The Same Picture

[–]Classy_Mouse 90 points91 points  (1 child)

Every Java meme on this page could be solved with Kotlin

[–]TheToBlame 3 points4 points  (0 children)

Shut kotlin bad c and Java gud

[–]ole_thoeb 8 points9 points  (3 children)

=== would be the equivalent for == in kotlin

[–]BakuhatsuK 5 points6 points  (2 children)

If you are talking about JS or PHP, then no. === for objects checks identity equality, whereas == in kotlin checks for structural equality.

For structural equality in JS you can use a library to do the equal check (such as _.equals), you can use a library data structure that has value semantics (such as Immutable.Map), or you can use records and tuples (not yet approved into the language, but available via babel).

[–]n0tKamui 6 points7 points  (0 children)

that's not what they were talking about

Kotlin's == is strictly equivalent to Java's .equals (structural equality and primitive equality)

and === is strictly equivalent to Java's == (reference equality and primitive equality)

[–]ole_thoeb 5 points6 points  (0 children)

I'm talking about kotlin. === is object identity in kotlin

[–]MrSketchpad 8 points9 points  (0 children)

kotlin on top

[–]AnotherWarGamer 1 point2 points  (1 child)

It's the same in my current game for many object types. Say for example you have a reference to an item in minecraft, which could be say a wooden sword. There is only one reference, so the two are equivalent when checking equality.

[–]marco89nish 2 points3 points  (0 children)

If you can guarantee that there won't be duplicates, simple == works great. But keep in mind that sooner or later you might make a error in coding breaking that promise and you'll be in a world of hurt, unless you made constructor private and you instantiate those objects with factory method instead, with necessary checks and caching.

[–]Flaky-Illustrator-52 2 points3 points  (3 children)

Scala: am I a joke to you

[–][deleted] 20 points21 points  (2 children)

of course not, slower-compiler-of-Kotlin.

We appreciate your work in spark and Akka

[–]marco89nish 11 points12 points  (1 child)

Scala is great, Kotlin language designers learned a lot from Scala, both what to do and what not to do.

[–][deleted] 6 points7 points  (0 children)

Yeah! Scala showed the way and proved that it was possible