Answer the question
In order to leave comments, you need to log in
When is it better to use variables with getters and when methods?
Here is my class:
/**
* All classes that has super class [Fragment] by default must extend this class instead of [Fragment]
*/
abstract class BaseFragment(
@LayoutRes resId: Int,
) : Fragment(resId) {
protected open val navigator get() = requireActivity() as Navigator
protected open val sharedData get() = requireActivity() as SharedData
}
abstract class BaseFragment(
@LayoutRes resId: Int,
) : Fragment(resId) {
protected open fun navigator() = requireActivity() as Navigator
protected open fun sharedData() = requireActivity() as SharedData
}
Answer the question
In order to leave comments, you need to log in
In this case, it doesn't matter at all. You need to use it in the most convenient way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question