9/10/2023 0 Comments Kotlin not null![]() In some programming languages, you can assign a null to any variable. We can try giving it a null when we construct Lucy’s CoffeeReview, but when we do that, we get an error: val lucyReview = CoffeeReview("Lucy", "Will buy this again!", null)Įrror: "Null can not be a value of non-null type Int" (does not compile) 2įor a review where there’s no star rating, we want to set stars to null. 1 A variable that is assigned null is like a bucket that is empty. Kotlin uses a keyword called null to represent the absence of a value.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |