score:8
Accepted answer
def something(num:int):boolean
and def something[s](num:s):boolean
have different method signatures. the argument type of the first is int
. the argument type of the second is the generic s
.
class foo extends a {
// you have to implement this abstract method
// that is inherited from b via a.
def something[s](num:s):boolean = ???
}
trait a extends b {
def something(num:int):boolean = {
num == 1
}
}
trait b {
def something[s](num:s):boolean
}
imagine trying to call the something[s](num:s)
method inherited from b
:
new foo().something[string]("x")
if you could get away with not implementing it, what would you expect to happen?
in the second example, since a
inherits b[int]
, the class generic s
is bound to int
, so the method that a
inherits is something(num:int)
, which does have the same signature as the implemented method.
Source: stackoverflow.com
Related Query
- class needs to be abstract since method in trait is not defined error
- underscore "class needs to be abstract since method is not defined" error
- class needs to be abstract since value element in trait is not defined
- protected method that takes an abstract super class instance and the "access to protected method not permitted" error
- Error on scala class : recursive method printExpr needs result type
- Scala: "class needs to be abstract, since method is not defined" error
- AsyncTask.doInBackground - abstract method not implemented error in Android Scala project
- Class needs to be abstract error while using traits in scala
- Error in running Scala Program: Main method not found in class main, please define the main method
- Type mismatch error when type is not defined in abstract class
- Scala abstract generic class with a generic method not compiling
- Why Scala reports error if does not specify this.type when using chain method in inherited class
- Getting an error in intellij referencing a scala method I'm not actually using in a class I have used
- class needs to be abstract since its members are not instantiated
- Spark Scala Error - Error: Main method not found in class
- scala Duration: "This class is not meant as a general purpose representation of time, it is optimized for the needs of scala.concurrent."
- Method is tail recursive when defined on object but not on class
- Scala IDE Error: Main method not found in class 'hello'
- Scala abstract class method that returns a new corresponding class child object
- Scala case class is not matched in receive method (in akka actors)
- Scala compiler error due to constructor parameter (property) having same name in both base and derived class and used in derived method
- Scala IDE Error -could not find/load main class
- Abstract and Final class defined on the same Scala Class
- Alternate constructor on Scala case class not defined: not enough arguments for method
- unapply method of a case class is not used by the Scala compiler to do pattern matching, why is that?
- A Scala method defined over two equal abstract types
- scala - Array("one", "two").mkString(":") defined in a method return WrappedArray, not a String
- Why is it not possible (in scala) to provide implementation for an abstract override method in the implementing base class
- Scala method clone in class Object cannot be accessed in T Access to protected method clone not permitted because
- Overriding abstract method of Java class in Scala with bounded inheritence
More Query from same tag
- What's the point of dependency injection if you still have to pass in an argument?
- Scala or java data structures for custom "non-strict" sorting
- Play Framework 20 - Creating a form in the view
- Scala: Why does Array.ofDim[String](n) create an Array where values are initialized as nulls rather than empty strings?
- Maven project from SBT project convertor?
- Slick batch insert (for Redshift JDBC)
- How to transpose/pivot the rows data to column in Spark Scala?
- Play: JSON Writes is not respected when class extends case class
- Cats leftMap seems to be unable to correctly infer type
- How to test XML contain node
- Play 2.2 match if there exists an implicit Json converter
- Is there a shorthand for selecting only one dataframe's columns after a join?
- Scala infix notation for generics
- How can I solve the Diverging implicit expansion for type
- Scala: Why use implicit on function argument?
- Lift Record: empty value for required field but no validation errors
- What does some syntax meaning in Scala?
- Class A cannot be cast to Class A after dynamic loading
- Scala identify string with pattern matching
- mvn exec:java on an sbt project
- Convert normal recursion to tail recursion with multiple recursive calls
- Spark RDD - CountByValue - Map type - order by key
- How to replace a value for a particular key in List[Row] in scala
- Scala - Access Object's field within Class Annotation
- Importing the 'val' package in Scala source
- Non-blocking DB drivers for Play framework
- Shapeless: generic lens parameterized by case class or field
- Is it reasonable to use Scala's REPL for comparative performance benchmarks?
- Way to reduce the redundancy in following boolean function definitions?
- Is there a good library to embed a command prompt in a scala (or java) application