Linked Questions
10 questions linked to/from How extend a class is diff from implicit class?
2028 votes
37 answers
518k views
Prefer composition over inheritance?
Why prefer composition instead of inheritance? What trade-offs are there for each approach? And the converse question: when should I choose inheritance instead of composition?
348 votes
7 answers
165k views
Understanding implicit in Scala
I was making my way through the Scala playframework tutorial and I came across this snippet of code which had me puzzled: def newTask = Action { implicit request => taskForm.bindFromRequest.fold( ...
61 votes
7 answers
39k views
Favor composition over inheritance [duplicate]
Favor composition over inheritance is very popular phrase. I read several articles and at the end each article says use inheritance when there is pure IS-A relationship between classes. An example ...
47 votes
2 answers
158k views
What is the difference between "IS -A" relationship and "HAS-A" relationship in Java? [duplicate]
I am new to JAVA and just started learning "IS-A" and "HAS-A" relation but I didn't really get it. What is the difference between "IS-A" and "HAS-A"? When ...
96 votes
3 answers
8k views
Implicit conversion vs. type class
In Scala, we can use at least two methods to retrofit existing or new types. Suppose we want to express that something can be quantified using an Int. We can define the following trait. Implicit ...
13 votes
2 answers
34k views
What is the Difference between inheritance and delegation in java [duplicate]
Possible Duplicate: Prefer composition over inheritance? What is the difference between inheritance and delegation in java? How to use the following example in my project? Please can you guide me ...
2 votes
1 answer
2k views
How to add extension method to a singleton object in scala 2?
I've stumbled upon this thread and there @prolativ provided some fancy scala 3 syntax for creating extension methods for objects extension (int: Int.type) def unapply(s: String): Option[Int] = s....
0 votes
1 answer
1k views
Understand Scala Implicit classes
I am reading a Spark in Action book, I came across a construct that even after a while working with Scala I still can't understand. Here is the code (complete code) : First we have a case class where ...
0 votes
1 answer
268 views
How to write an implicit Numeric for a tuple
I have a scenario where I would like to call sum on a sequence of (Double, Double) tuples. Ideally I would like to do something like the following: implicit def toTupleNumeric[T](num: Numeric[T]) = ...
0 votes
1 answer
218 views
How import spark.sqlContext.implicits._ works in scala?
I'm new in Scala Here's what I'm trying to understand This code snippet gives me RDD[Int], not give option to use toDF var input = spark.sparkContext.parallelize(List(1,2,3,4,5,6,7,8,9)) But when I ...