![]() Above all, however, we gain time (less w̵r̵i̵t̵i̵n̵g̵ copy-pasting) and safety (prevents us from forgetting about one of the thousands of cloned lines when changing one, faulty line of code.) Shining example is different types of collections. With a little work, it allows us to generalize the code for a theoretically infinite number of cases, making our program clean, readable and flexible. ![]() Another fantastic thing we use every day. Write Once - Use in Thousands of Different Cases. As if that was not enough, the compiler also knows it thanks to which we will get a program definitely more efficient than its counterparts written using dynamically typed languages. Moreover, our IDE also knows it and hence very often our coding will come down to choosing the appropriate hint from the list. If we are working with an object of some type, we know for sure that it contains fields and methods of this type and we can safely refer to them. It allows us to forget about at least one source of problems. Type safety is a great feature of all statically typed languages. ![]() ![]() Especially the last one does not make any sense. ![]() Original: Employee(empName=Adam Baer, empId=123,ĮmpAge=45, empCity=Norway) || Copied: Employee(empName=Adam Baer, empId=123, empAge=45, empCity=Norway) Destructuringĭestructuring allows us to break a data class in Kotlin into individual fields.And the result is: boolean false boolean false string true boolean true string false boolean trueĭo you see any logic here? Me neither. (What this also means is for these classes, you won’t have a lot of member functions as a part of the class). A lot of times in the applications you would need classes solely for the purpose of storing data in the objects and you would use those objects to set/retrieve values of corresponding properties. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |