> Declaring values is done using either "var" or "val". "val" declarations cannot be reassigned, whereas "vars" can. I wonder why they decided on these very mistakable names. Why not const/constant/cons/whatever else just as long it's distinguishable from each other?
var = variable (can vary/change) val = value (constant) What can be mistaken?
Learn Kotlin in Y Minutes
171–180 of 239 posts
Re: Learn Kotlin in Y Minutes
#172Re: Learn Kotlin in Y Minutes
#173the whole kotlin debate is just a misguided stab at solving the pain that is programming for android. everyone everywhere hates android dev work. so they think that it must be java. no, java sucks, but kotlin sucks just the same. the problem is the android ecosystem as a whole. the ever changing apis. etc. wasting time on java vs kotlin is absurd with so many other real problems.
God, what a useless post. If you don't like Android development don't waste your time with it.
Re: Learn Kotlin in Y Minutes
#174Earlier quoted context omitted.
Except when iterating through a hash, where 'key' and 'val' are my go-to names for stuff
Just use 'value'. Only you can be sure of shortened words even if it looks obvious. Not good in a team. I never understood people who shorten words to make the program look cryptic. Maybe it was someone who taught you how to program had it that way or somehow it makes you feel your program looks cooler if it looks more cryptic.
Re: Learn Kotlin in Y Minutes
#175Earlier quoted context omitted.
Except when iterating through a hash, where 'key' and 'val' are my go-to names for stuff
Just use 'value'. Only you can be sure of shortened words even if it looks obvious. Not good in a team. I never understood people who shorten words to make the program look cryptic. Maybe it was someone who taught you how to program had it that way or somehow it makes you feel your program looks cooler if it looks more cryptic.
Re: Learn Kotlin in Y Minutes
#176Earlier quoted context omitted.
I'm guessing the parent is just complaining that if you are reading code very fast (particularly if you're browsing repositories on your phone) it is hard to distinguish between "val" and "var."
Let alone type them wrong on a tired night.
Re: Learn Kotlin in Y Minutes
#177Does Kotlin have its own class/libraries or it still uses Java's classes?
Re: Learn Kotlin in Y Minutes
#178Earlier quoted context omitted.
Let alone type them wrong on a tired night.
Thankfully that would be a simple compile-time error. The message might even be readable.
(I'm sure that this is just something you need to get used to, I'm merely trying to point out that this could be a silent typo/mistake)
Re: Learn Kotlin in Y Minutes
#179Earlier quoted context omitted.
my beef is with 'val' being keyword. How many variables did you name val in all your coding? I certainly did.
`val` is never an appropriate name for a variable because it tells you nothing at all about what the variable contains.