When declaring literal numbers such as
Long
orFloat
, use upper case suffix. For example, prefer2L
to2l
.
Depending on the font and the syntax highlighting scheme, some letters look a lot like numbers. In some configurations, for example, l
(lower case L
) and 1
(one) are basically indistinguishable. Github, for instance, while not the worst offender, isn’t doing a great job there.
To the casual reader, the following has a fair chance of looking like a list of Int
s, but a Long
sneaked in:
List(1, 11, 111, 111l, 11111, 11111, 11111)
Using upper-case letters makes this more obvious:
List(1, 11, 111, 111L, 11111, 11111, 11111)
Linter | Rule |
---|---|
Scalastyle |