Programming in Kotlin - Part 73: Challenge: | Ray Wenderlich Videos

Challenge time! Practice using properties through a hands-on challenge.

This is a companion discussion topic for the original entry at

I am just curious why you prefer &recommend lateinit over Optionals ( 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)