ezoic

Monday, May 1, 2017

List, or Array, or RDD can not be used as data type solely in class on scala

For example, such program will have error, "type List takes Type parameters".


import java.io._ class
class Point(val xc: List, val yc: List)
 { var x: List= xc var y: List = yc
 def move()
{ val result=x.intersect(y)
 println ("Length of intersection" + result.length);
 } }
object Demo { def main(args: Array[String])
{ val pt = new Point(List("a","u","r"),List("a","q","r"));
 pt.move();
 }
}

You need to write something like:
import java.io._ class
class Point(val xc: List[String], val yc: List[String])
 { var x: List[String]= xc var y: List[String]= yc
 def move()
{ val result=x.intersect(y)
 println ("Length of intersection" + result.length);
 } }
object Demo { def main(args: Array[String])
{ val pt = new Point(List("a","u","r"),List("a","q","r"));
 pt.move();
 }
}





No comments:

Post a Comment

looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...