what is the difference or no difference in the following two approaches:
1.
private lateinit var binding: ResultProfileBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ResultProfileBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
}
private var _binding: ResultProfileBinding? = null
// This property is only valid between onCreateView and onDestroyView.
private val binding get() = _binding!!
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_binding = ResultProfileBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
}
The above sample code are from: https://developer.android.com/topic/libraries/view-binding. one use lateinit for Activity the other use one computed property backed by optional var for Fragment.
Both seem to work in Fragment and Activity, but this get me curious: is there any differences in Kotlin language?