What is the difference between self-types and trait subclasses?

It is predominately used for Dependency Injection, such as in the Cake Pattern. There exists a great article covering many different forms of dependency injection in Scala, including the Cake Pattern. If you Google “Cake Pattern and Scala”, you’ll get many links, including presentations and videos. For now, here is a link to another question. … Read more

What do all of Scala’s symbolic operators mean?

I divide the operators, for the purpose of teaching, into four categories: Keywords/reserved symbols Automatically imported methods Common methods Syntactic sugars/composition It is fortunate, then, that most categories are represented in the question: -> // Automatically imported method ||= // Syntactic sugar ++= // Syntactic sugar/composition or common method <= // Common method _._ // … Read more

What is the difference between Scala’s case class and class?

Case classes can be seen as plain and immutable data-holding objects that should exclusively depend on their constructor arguments. This functional concept allows us to use a compact initialization syntax (Node(1, Leaf(2), None))) decompose them using pattern matching have equality comparisons implicitly defined In combination with inheritance, case classes are used to mimic algebraic datatypes. … Read more

What are all the uses of an underscore in Scala?

The ones I can think of are Existential types def foo(l: List[Option[_]]) = … Higher kinded type parameters case class A[K[_],T](a: K[T]) Ignored variables val _ = 5 Ignored parameters List(1, 2, 3) foreach { _ => println(“Hi”) } Ignored names of self types trait MySeq { _: Seq[_] => } Wildcard patterns Some(5) match … Read more

Is the Scala 2.8 collections library a case of “the longest suicide note in history”? [closed]

I hope it’s not a “suicide note”, but I can see your point. You hit on what is at the same time both a strength and a problem of Scala: its extensibility. This lets us implement most major functionality in libraries. In some other languages, sequences with something like map or collect would be built … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)