It is telling me that a return type is required for the constructor. I looked it up in the 5th edition of Android Programming Big Nerd Ranch and saw that it was the same. I don’t know why it’s highlighting the private and constructor keywords.
None of the errors show up when I make the project, yet it is highlighting the keywords like there is an error.
package com.bignerdranch.android.criminalintent;
import android.content.Context;
class CrimeRepository private constructor(context: Context){
companion object {
private var INSTANCE: CrimeRepository? = null
fun initialize(context: Context) {
if (Instance == null) {
INSTANCE = CrimeRepository(context)
}
}
fun get(): CrimeRepository {
return INSTANCE ?:
throw IllegalStateException("CrimeRepository must be initialized")
}
}
}