Hi Everyone,
just discovering Kotlin and intelliJ 2 days ago. Really love the easy language syntax…
Wondering - starting with the easiest errors, how to treat those Typo errors, related to non english Var names…I guess the Warnings are here to help avoiding code bugs, so its fine for me…But how do you work with those ?
Firstly, I’d recommend writing code in English, to make it consistent with keywords and standard library.
That said, this inspection applies to docs and string literals as well, where using different language may sometimes be intended. For configuration of spellchecking you can relate to this page: Spellchecking | IntelliJ IDEA
I’ve seen a youtube demo where the plural in an expression plus its singular were used to difrenciate “a record” …From its “array” such as :
greeting from greetings
…but later I saw that a similar plural distinction was used within the variable name : itemSoflist …(if I got that right)
I thought Kotlin could only “understand” the difference if the “S” (or plural) was located at the end of a var name:
player / players
-So, is there really some Syntax rule that helps Kotlin to diferenciate a plural “s” rule within a var name ???
itemsinstock / iteminstock ?
*quite amazing …while so logical indeed !
Variable names have nothing to do whatsoever with what type a variable is. They are there solely to help you as a developer to understand and work with the code. What you’re talking about is probably type inference where if you assign a variable without specifying a type, it’ll automatically know what type you wanted solely based on the type of the expression on the right hand side.
val accents = arrayOf("french","english","spanish")
accents.forEachIndexed {index, accent ->
print(" $accent:$index")
…Hmm…so you mean one could use any word in place of the word “accent”, while the array is still named “accents” and it still would work ???
eheheh, I though Kotlin gramatical A.I was already being used here
(maybe in coming debugger versions)
Lol yeah. Most programming languages don’t care at all what you call your variables. In fact, what happens when you compile Kotlin or Java and run it through a minifier like proguard is that literally all of the variable names just become 3 letter words except for any publicly facing stuff.