我来自Java背景,是Scala的新手.
I am from a Java background and new to Scala.
我正在使用Scala和Spark.但是我无法理解在哪里使用==和===.
I am using Scala and Spark. But I'm not able to understand where I use ==and ===.
任何人都可以让我知道在哪种情况下我需要使用这两个运算符,并且==和===有什么区别?
Could anyone let me know in which scenario I need to use these two operators, and what's are difference between == and ===?
推荐答案"=="正在使用equals方法,该方法检查两个引用是否指向同一对象. "==="的定义取决于上下文/对象.对于Spark,"==="正在使用equalTo方法. 见
The "==" is using the equals methods which checks if the two references point to the same object. The definition of "===" depends on the context/object. For Spark , "===" is using the equalTo method. See
- 用于== spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equals(java.lang.Object)
- 对于=== spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equalTo(java.lang.Object)
- for == spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equals(java.lang.Object)
- for === spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equalTo(java.lang.Object)
(因为您正在引用Spark :) Spark的一个重要区别是返回值.对于列:
(Since you are referencing Spark:) An important difference for Spark is the return value. For Column:
-
==返回一个布尔值
===返回一列(其中包含两列元素的比较结果)
=== returns a column (which contains the result of the comparisons of the elements of two columns)
更多推荐
Scala,Spark中==和===之间的区别
发布评论