What will be the result of combining Strings for a Monoid?
import cats.implicits._
import cats.kernel.Monoid

Monoid[String].combineAll(List("a", "b", "c"))
Monoid.combineAll performs operation combine for all elements with zero element. In the current example, zero element for Strings is empty String "", which being concatenated with other elements of the lists results in "abc".

Source: Scala Exercises: cats monoid

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Scala quizzes
Sign Up Now
or Subscribe for future quizzes