Scala: error: value unary_+ is not a member of (Int, Int)

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 22 in Apache Spark by Haman
90 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". 

This issue is not yet resolved. But there is a  workaround for this. Refer the below screenshot for the same,image

answered Jul 22 by karan

Related Questions In Apache Spark

0 votes
1 answer

Scala: 30: error: value partitions is not a member of String

Try this code: val rdd= sc.textFile (“file.txt”, 5) rdd.partitions.size Output ...READ MORE

answered Jul 29 in Apache Spark by Nijit
58 views
0 votes
1 answer

Error: value textfile is not a member of org.apache.spark.SparkContext

Hi, Regarding this error, you just need to change ...READ MORE

answered Jul 4 in Apache Spark by Gitika
• 25,360 points
260 views
0 votes
1 answer
0 votes
1 answer

How to use yield keyword in scala and why it is used instead of println?

Hi, The yield keyword is used because the ...READ MORE

answered Jul 5 in Apache Spark by Gitika
• 25,360 points
74 views
0 votes
1 answer

Copy all files from local (Windows) to HDFS with Scala code

Please try the following Scala code: import org.apache.hadoop.conf.Configuration import ...READ MORE

answered May 22 in Apache Spark by Karan
425 views
0 votes
1 answer

Scala pass input data as arguments

Please refer to the below code as ...READ MORE

answered Jun 19 in Apache Spark by Lisa
47 views
0 votes
1 answer

Doubt in display(id, name, salary) before display function

The statement display(id, name, salary) is written before the display function ...READ MORE

answered Jun 19 in Apache Spark by Ritu
30 views
0 votes
1 answer

How to calculate the result of formula with Scala?

Hi, You can use a simple mathematical calculation ...READ MORE

answered Jul 1 in Apache Spark by Gitika
• 25,360 points
52 views
0 votes
1 answer

Error : split value is not a member of org.apache.spark.sql.Row

spark.read.csv is used when loading into a ...READ MORE

answered Jul 10 in Apache Spark by Rishi
543 views
0 votes
1 answer

Error : split value is not a member of org.apache.spark.sql.Row

spark.read.csv is used when loading into a ...READ MORE

answered Jul 22 in Apache Spark by Firoz
404 views