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, 2019 in Apache Spark by Haman
3,420 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

Hope this helps!

To know more about Spark Scala, It's recommended to join Apache Spark training online today.

Thanks!!

answered Jul 22, 2019 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, 2019 in Apache Spark by Nijit
3,391 views
+1 vote
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, 2019 in Apache Spark by Gitika
• 65,770 points
4,362 views
0 votes
1 answer
0 votes
1 answer
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, 2019 in Apache Spark by Karan
4,199 views
0 votes
1 answer

Scala pass input data as arguments

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

answered Jun 19, 2019 in Apache Spark by Lisa
2,452 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, 2019 in Apache Spark by Ritu
667 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, 2019 in Apache Spark by Gitika
• 65,770 points
1,281 views
0 votes
2 answers

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

var d=rdd2col.rdd.map(x=>x.split(",")) or val names=rd ...READ MORE

answered Aug 5, 2020 in Apache Spark by Ramkumar Ramasamy.
11,933 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, 2019 in Apache Spark by Firoz
3,090 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