![]() ![]() ![]() But I'm now wondering if I should even be declaring a group of functions as an object.Įver since I first learned about the keyword object I've been making everything an object when I don't see a need to make more than one of something ( I seem to have trouble thinking in terms of objects, so I rarely ever use class ).ġ.19.3 will become the default version in the coming weeks. I've tried searching how to know when to make something an object vs just making a file with top level functions, and the views seem to be split on the issue ( the views seem to be split between: object should be used, object should almost never be used, and it doesn't really matter which is used ). I have my latest project up on GitHub, I've made two versions of it, one with using the keyword object and one without, and I was wondering which version is better ( I should note that other students were able to solve the project with 2/3 less code using regex, but I haven't learned how to use that yet ). Here's a brief example of my PostFix as an object for those that don't want to look at my GitHub files:įun convert(infix: String): Array // convert was renamed to be more concise, since it is no longer being called with the object name.Īlso, for the purpose of the class I'm in, the main file has to be named Main and I was wondering if that is common practice to name the main file that? ( as with my alt version it's not descriptive of what it contains, like with my version with object use, the main file just makes a call to the SmartCalculator object, where the alt version has the guts of it within the main file ).I'm learning kotlin and i'm trying to make a program that calculates the average speed. My program crashes trying to calculate the average speed in kotlin and i have no idea why it is giving this error and how to fix it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |