Ruby logoRuby/
RB-PR1010

Do not compute the size of statically sized objectsRB-PR1010

Major severityMajor
Performance categoryPerformance

Sizes of objects that we know to be static should not be computed.

For example, we know the size of array in the snippet below to be 3. We can directly use the value instead of calculating it first.

Bad practice

[1, 2, 3].count
[1, 2, *arr].count