02/22/2022, 12:33 PM
Hey guys, is there a specific naming convention for class fields which has a number in their name ?
class Apartment ( val room1: String, val room2: String )


02/22/2022, 12:34 PM
Not that I know of. I always saw such variables/properties written the way you did here. If another word followed the number, it would usually be capitalized, as if the number were a word.
That said, note that there are many cases where you can avoid numbers. If the different variables don't play the same role, you could use some word to express that difference:
copy(sourceFile: Path, targetFile: Path)
. If they play symmetric roles, sometimes you can use a list instead. This is true in particular if all those properties are often processed/accessed together in the same way, because an iteration is usually easier to deal with than repeating the same code for each property. In the case of apartment rooms, maybe you're in this case (depends on the usage).
:thank-you: 1