underscoreio/essential-scala

Final case object

Closed this issue · 1 comments

Throughout the book there are code examples like the following

sealed trait IntList
final case object End extends IntList
final case class Pair(head: Int, tail: IntList) extends IntList

While I agree it is good practice to declare everything that should/can final as final. I am unsure if I understand why it is used for object. You can not subclass an object, so it is redundant here(?). Am I missing something?

Thanks for the issue! No, you're not missing anything -- the keyword is redundant, as you say. I've removed it in 3a8b67e.