Bhaskar Singh
07/10/2025, 7:26 AM.size and .length in Kotlin. Sometimes they are properties, sometimes functions — and it's not always clear which to use for what type.
For example:
• String uses .length
• Array and List use .size
• StringBuilder uses .length() (function)
•
Is there a consistent rule or guideline in Kotlin for when to use .size vs .length, and when it's a property vs a function?
Would love to hear how others mentally organize this!
Thanks in advance 🙏CLOVIS
07/10/2025, 7:27 AM.size . .length in String and StringBuilder are legacy decisions that were inherited from Java for better interoperability