Query regarding Operator Overloading in Scala

0 votes

Hi,

I tried to create a function of "+", so after creating while calling the function showing below error. Could you please help me out?

scala> def +(FirstValue: Int, SecondValue: Int): Int = FirstValue+SecondValue

$plus: (FirstValue: Int, SecondValue: Int)Int

scala> +(2,5)

<console>:24: error: value unary_+ is not a member of (Int, Int)

       +(2,5)

       ^

Jul 10, 2019 in Apache Spark by Rachit
783 views

1 answer to this question.

0 votes

All prefix operators' symbols are predefined: +, -, ~, !. The Scala parser treats these symbols at the beginning of expressions always as unary operators regardless of the real presence of corresponding methods "unary_x". But there is a  workaround for this. Refer the below screenshot

image

answered Jul 10, 2019 by Karan

Related Questions In Apache Spark

0 votes
1 answer

Which query to use for better performance, join in SQL or using Dataset API?

DataFrames and SparkSQL performed almost about the ...READ MORE

answered Apr 19, 2018 in Apache Spark by kurt_cobain
• 9,310 points
250 views
0 votes
1 answer

Query regarding a spark split logic

First, import the data in Spark and ...READ MORE

answered Feb 9, 2019 in Apache Spark by Omkar
• 69,060 points
52 views
0 votes
1 answer

Multidimensional Array in Scala

Multidimensional array is an array which store ...READ MORE

answered Feb 11, 2019 in Apache Spark by Omkar
• 69,060 points
476 views
0 votes
1 answer

where can i get spark-terasort.jar and not .scala file, to do spark terasort in windows.

Hi! I found 2 links on github where ...READ MORE

answered Feb 13, 2019 in Apache Spark by Omkar
• 69,060 points
298 views
+1 vote
2 answers
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,920 points
5,109 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,920 points
730 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyF ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
30,381 views
0 votes
1 answer

Query regarding Appending " to a string in Scala

You can perform this task in two ...READ MORE

answered Jul 10, 2019 in Apache Spark by Esha
860 views
0 votes
1 answer

How to create RDD from parallelized collection in scala?

Hi, You can check this example in your ...READ MORE

answered Jul 3, 2019 in Apache Spark by Gitika
• 29,690 points
307 views