![]() In this simple app, we’re just going to save the data to a text file instead of over complicating it with SQLite. We’ve had our class implement Serializable.So in this case, we have a constructor that can be used as Task("Description") and it will default to incomplete, or we can call it with Task("Description", true) to set the initial value of the completed boolean. Kotlin allows for default constructors to be defined right with the class name.A data class is a special class in Kotlin that provides you with default behaviors for all your Object methods like toString() hashCode() equals() and copy(). ![]() You may not believe it, but that’s all we need. Data class Task ( var description : String, var completed : Boolean = false ) : Serializable ![]()
0 Comments
Leave a Reply. |