Linked Questions
19 questions linked to/from Difference between object and class in Scala
146 votes
9 answers
11k views
Why is a static method considered a method?
I'm writing an explanation for some code for a course, and have been accidentally using the words method and function interchangeably. I decided to go back over and fix the wording, but ran into a ...
8 votes
3 answers
856 views
Scala - are classes sufficient?
Coming from Java I am confused by the class/object distinction of scala. Note that I do not ask for the formal difference; there are enough references on the web which explain this, and there are ...
2 votes
2 answers
2k views
Understanding class and object in scala
I'm very new to scala and now I have to work on a project which is written both in scala and java. I came across with this-like construction: class SomeType{ //... } trait Trait1 extends scala....
5 votes
5 answers
908 views
Cannot compile file in Scala
From an example in book "Begining in Scala", the script is: import scala.collection.mutable.Map object ChecksumAccumulator { private val cache=Map[String,Int]() def calculate(s: String):Int = ...
5 votes
2 answers
5k views
Can an object extend abstract class in scala?
I am newbie to scala . I am trying to create an Object that extends abstract class like show below object Conversions extends UnitConversions { override def inchesToCentimeters(inches:Int) = inches *...
5 votes
1 answer
5k views
Scala Functions as object vs class
trait MyFunctionTrait extends ((Int, Int) => Double) class MyFunction1 extends MyFunctionTrait { override def apply(a: Int, b: Int) => Double = a/b } object MyFunction2 extends ...
-2 votes
2 answers
935 views
Difference between an object in Java versus an object in Scala
I have started learning Scala.Is there any difference between an object in Java versus an object in Scala. As per my understanding the object created in Scala is singleton. Any other pointers please.
1 vote
2 answers
734 views
How to determine if `this` is an instance of a class or an object?
Suppose I have two descendants of an abstract class: object Child1 extends MyAbstrClass { ... } class Child2 extends MyAbstrClass { } Now I'd like to determine (preferably in the constructor of ...
0 votes
3 answers
195 views
How to read class/object in Scala documentation
I just learned Scala. When I read official documentation to look up Array, for example, it has two versions. One is for Class, the other is for Object. I think I know the difference between Class and ...
1 vote
1 answer
437 views
wrapping around generic callback function with different signatures
I am trying to learn Scala and it seems like a very powerful language so far, but some things seem hard to achieve, may be its just my learning curve. I have researched online for a few days but could ...
2 votes
1 answer
573 views
Scala error: Exception in thread "main" org.apache.spark.SparkException: Task not serializable
I got not serializable error when running this code: import org.apache.spark.{SparkContext, SparkConf} import scala.collection.mutable.ArrayBuffer object Task1 { def findHighestRatingUsers(...
0 votes
2 answers
118 views
Connecting case class with object in model
I have started learning about Play, and in the tutorials that I saw, the model usually has two components: a case class and an object. I have created a model with an object and a case class. My ...
3 votes
1 answer
249 views
Dynamic import from object instead of package
I'm reading the MEAP of the second edition of "Functional Programming in Scala" and I ran across the following in a listing: In Parsers.scala: trait Parsers[Parser[+_]]: ... extension [A]...
0 votes
2 answers
170 views
Why are classes created inside Objects in Scala
I don't understand why sometimes class are created inside an object in Scala, just like the following code shows. object polynomials { class Poly(terms0: Map[Int, Double]) { val terms = terms0 ...
0 votes
1 answer
325 views
Creating a communication stream between a server and a local process
I've been trying, for some time now, to create a local process that will act as a CLI for my server. The idea is similar to what Drush does for Drupal servers. I haven't created the CLI interface yet ...