Comments (9)
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.
@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.
If it does not matter, then I would like to close this anyway.
from scala-style-guide.
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.
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.
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.
Hm.. cc @rxin too. Do you have any preference or think it is something we should not bother for now?
from scala-style-guide.
I don't have a strong preference. It doesn't really hurt my eye ...
from scala-style-guide.
Let me close this for now. I will reopen when I happen to get a better reason.
from scala-style-guide.
Related Issues (17)
- Question on: "Avoid defining apply methods on classes" HOT 2
- Is there any editorconf settings for the IDEs? HOT 12
- Synchronized definitions which exceed 100 columns HOT 2
- Update apply method section in Chinese translation HOT 1
- Adding Korean version of guide line. HOT 16
- Thoughts about Option.get HOT 2
- Revisit non-scalaish recommendations HOT 8
- Discourage changing external API's method signature for binary compatibility HOT 3
- Automated checks for CI ? HOT 3
- Multi-line vs single-line method and class constructor declarations and invocations HOT 5
- ConcurrentMap qualifications HOT 1
- Constants Naming Convention
- Clarifying whitespace guidelines for classes
- Missing "t" in the last section
- Make it clear that there must be a space between class declaration and curly braces
- Do we have any spark scala syntax to read edi files into data frame
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-style-guide.