HiddenLayer555@lemmy.ml to Programming Humor@lemmy.worldEnglish · 25 days agoWhy make it complicated?lemmy.mlexternal-linkmessage-square13fedilinkarrow-up130arrow-down13file-textcross-posted to: [email protected]
arrow-up127arrow-down1external-linkWhy make it complicated?lemmy.mlHiddenLayer555@lemmy.ml to Programming Humor@lemmy.worldEnglish · 25 days agomessage-square13fedilinkfile-textcross-posted to: [email protected]
minus-squaremacniel@feddit.orglinkfedilinkEnglisharrow-up3·edit-225 days agoKotlin knows mutable and immutable variables. var indicate mutables and val would indicate immutables (comparable with the final modifier in java and const in JavaScript/TypeScript).
minus-squareuranibaba@lemmy.worldlinkfedilinkEnglisharrow-up1·24 days agoSo a var can start as a string and later be an integer?
minus-squaremacniel@feddit.orglinkfedilinkEnglisharrow-up2·24 days agoNo, the type is strict and fixed.
minus-squareguillem@aussie.zonelinkfedilinkEnglisharrow-up2·24 days agoI don’t know Kotlin but in other languages “(im)mutable” refers to the value, not the type.
Kotlin knows mutable and immutable variables.
var
indicate mutables andval
would indicate immutables (comparable with thefinal
modifier in java andconst
in JavaScript/TypeScript).So a var can start as a string and later be an integer?
No, the type is strict and fixed.
I don’t know Kotlin but in other languages “(im)mutable” refers to the value, not the type.