Post AWHaigjYkrdbfmQ9jc by alexelcu@social.alexn.org
 (DIR) More posts by alexelcu@social.alexn.org
 (DIR) Post #AWHYWiSOK4wjdLYPb6 by alexelcu@social.alexn.org
       2023-06-02T13:26:55Z
       
       0 likes, 0 repeats
       
       In #Scala 3, Ints and Strings can no longer be compared with ==.This is due to the introduced “multiversal equality” (the `CanEqual` type-class): https://docs.scala-lang.org/scala3/reference/contextual/multiversal-equality.html
       
 (DIR) Post #AWHYbKKpR2piGiDPW4 by dhinojosa@mastodon.social
       2023-06-02T13:27:44Z
       
       0 likes, 0 repeats
       
       @alexelcu Strictness for the win
       
 (DIR) Post #AWHZ7BFSkp3FLztVqq by alexelcu@social.alexn.org
       2023-06-02T13:33:31Z
       
       0 likes, 0 repeats
       
       Unless you `import scala.language.strictEquality`, use of `CanEqual` isn't mandated by default.However, once you implement a `CanEqual` for a type, its use is mandatory. See screenshots.#Scala3
       
 (DIR) Post #AWHaO1Hb9v7jK6UEnw by vascorsd@mastodon.social
       2023-06-02T13:47:44Z
       
       0 likes, 0 repeats
       
       @alexelcu hmm, so by the page primitive types have the CanEqual defined so can only be compared with themselves. I see Seq is also defined. Do Options also have CanEquals properly defined?This opened up so many questions. I thought it was a default for everything, even for what people do most, which is defining case classes, but for that to be default I still have to turn the flag on the compiler on.I'll have to test some things. :thaenkin:
       
 (DIR) Post #AWHaigjYkrdbfmQ9jc by alexelcu@social.alexn.org
       2023-06-02T13:51:30Z
       
       0 likes, 0 repeats
       
       @vascorsd If you have CanEqual, then it's used. Otherwise, to ban any other kind of equality, the compiler flag needs to be on.Given the backwards compatibility concerns, honestly, this is better than I expected.Options seem not to have CanEqual properly defined. I wonder what the plan is for them.
       
 (DIR) Post #AWHblECHPUw3zTd5Tk by alexelcu@social.alexn.org
       2023-06-02T14:03:10Z
       
       0 likes, 0 repeats
       
       @vascorsd Options seem to work fine if you `import scala.language.strictEquality`.On first glance, this is kind of weird, TBH, because I can't see how they can work without a CanEqual instance defined.
       
 (DIR) Post #AWHkrb5k6JkKK0gRl2 by kevinlee@hachyderm.io
       2023-06-02T15:45:08Z
       
       0 likes, 0 repeats
       
       @alexelcu @vascorsd Option has CanEqual instances. I remember I added it about 2 years ago as I really wanted to use strict equality. https://github.com/lampepfl/dotty/pull/12419