Skip to content

Files

Latest commit

 

History

History
25 lines (17 loc) · 387 Bytes

Style-ArrayFirstLast.md

File metadata and controls

25 lines (17 loc) · 387 Bytes

Pattern: Use of arr[0]/arr[-1]

Issue: -

Description

Identifies usages of arr[0] and arr[-1] and suggests to change them to use arr.first and arr.instead.

Examples

# bad
arr[0]
arr[-1]

# good
arr.first
arr.last
arr[0] = 2
arr[0][-2]

Further Reading