Sudhir Singh Khanger
09/19/2018, 7:24 AMprivate val
. It can be as follows.
class MainViewModel @Inject constructor(movieRepository: MovieRepository) : ViewModel() {
val movieList: LiveData<List<MovieEntry>> = movieRepository.getMovies()
}
It isn't making me much sense when to use val/var and when to not.
Constructor parameters must use var or val when they are used as a property elsewhere in the class.What does it mean by when used
as a property
?
https://stackoverflow.com/questions/45821929/in-which-situation-val-var-is-necessary-in-kotlin-constructor-parameter