While exploring some repositories on GitHub I found some people define fields twice for example
private var _binding: FragmentBinding? = null
private val binding: FragmentBinding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentBinding.inflate(layoutInflater)
return binding.root
}
why do some developers do this and why not just define the field once
private var binding: FragmentBinding? = null