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
1,664 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,350 points
1,825 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,220 points
521 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,220 points
1,925 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,220 points
1,341 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
• 11,380 points
11,028 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
• 11,380 points
2,535 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
108,831 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
2,419 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 4, 2019 in Apache Spark by Gitika
• 65,770 points
1,602 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP