Challenge time! Practice using properties through a hands-on challenge.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4736-programming-in-kotlin/lessons/73
Challenge time! Practice using properties through a hands-on challenge.
I am just curious why you prefer &recommend lateinit over Optionals (https://videos.raywenderlich.com/courses/128-programming-in-kotlin/lessons/70) to avoid β?β to safely access properties? as from what you suggested, even this example code in challenge looks like there is no init {} here to make sure teacherName is initialized or have a default value OR at least could have been an optional, and courseDescription could have used an elvis operator to avoid exceptions.
Given this code will throw an exception if you forget to call //course.setTeacherName(βMs Priceβ)
And try to access to courseDescription (given it needs teacherName)