lunduniversity / introprog

Teaching material for "Introduction to Programming using Scala" at Lund University, LTH. http://cs.lth.se/pgk/
140 stars 167 forks source link

10.1.33 sealed trait, need to add only stops subtyping from other files #707

Closed JonatanKrakhede closed 1 year ago

JonatanKrakhede commented 1 year ago

"Nyckelordet sealed förhindrar vidare subtypning av Färg och ger varning om matchning inte är fullständig, vilket är hjälper dig att inte orsaka körtidsfel."

Should probaly add that it only stops subtyping form other code files, does not hinder when trying to subtype in the same file as the sealed trait. This was probaly explained in chapter 6, but if it's being explained again might as well add that to not confuse anyone. Like me, who had to check my notes to make sure I was not mad.

bjornregnell commented 1 year ago

Yes good point! The rule for sealed should include "in other code files" or similar.