Giter Club home page Giter Club logo

Comments (9)

aarondav avatar aarondav commented on May 18, 2024

As of I think Scala 2.10, ScalaTest's assert is a macro which does print nice error messages. If you're working in a 2.10+ codebase, I would recommend double equals, as triple equals can be hard to remember, especially when it's unnecessary.

from scala-style-guide.

HyukjinKwon avatar HyukjinKwon commented on May 18, 2024

@aarondav Thank you so much for your comment!
I feel like it would be great if it is documented regardless of which one is preferred because apparently they are being used in a mixed way in Spark and it seems some prefer == whereas other do === including Spark committers.

from scala-style-guide.

HyukjinKwon avatar HyukjinKwon commented on May 18, 2024

If it does not matter, then I would like to close this anyway.

from scala-style-guide.

aarondav avatar aarondav commented on May 18, 2024

Feel free to add a section recommending == -- I think having a guideline here is very reasonable, especially since there's some history behind it.

from scala-style-guide.

HyukjinKwon avatar HyukjinKwon commented on May 18, 2024

Hi, @aarondav,
I just simply ran the tests as below (my scala version is 2.11.6):

  • assert(1 == 2)

    org.scalatest.exceptions.TestFailedException was thrown.
    
  • assert(1 === 2)

    1 did not equal 2
    

I ran this within my local and then also tried this with unit tests in Spark.

Am I missing something?

from scala-style-guide.

HyukjinKwon avatar HyukjinKwon commented on May 18, 2024

But it seems apparently okay with other comparisons for example as below (not using constant) although I don't know why:

val a = 1
val b = 2
assert(a == b)

produces

1 did not equal 2

So, If you think it is fine, I will submit a PR with saying things such as ...

"... == is encouraged because triple equals can be hard to remember, especially when it's unnecessary and this might confuse newbies of Scala developers ...".

from scala-style-guide.

HyukjinKwon avatar HyukjinKwon commented on May 18, 2024

Hm.. cc @rxin too. Do you have any preference or think it is something we should not bother for now?

from scala-style-guide.

rxin avatar rxin commented on May 18, 2024

I don't have a strong preference. It doesn't really hurt my eye ...

from scala-style-guide.

HyukjinKwon avatar HyukjinKwon commented on May 18, 2024

Let me close this for now. I will reopen when I happen to get a better reason.

from scala-style-guide.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.