Does Kotlin have the equivalent of Unplicitly Unwrapped Optionals in Swift?

Implicitly deployed options are a useful Swift function for things like user interface elements that are not assigned during class constructor, but we can safely assume that for most functions (like they were assigned in viewDidLoad).

eg.

@IBOutlet weak var textView : UITextView! 

Is there an equivalent for Kotlin, or a workaround that achieves the same effect?

+4
source share
1 answer

lateinit varmay be a suitable solution. Kotlin simply assumes that they are not equal to zero. https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties

+9
source

Source: https://habr.com/ru/post/1676287/


All Articles