Skip to content

Files

Latest commit

 

History

History
29 lines (21 loc) · 591 Bytes

Style-RedundantArrayConstructor.md

File metadata and controls

29 lines (21 loc) · 591 Bytes

Pattern: Redundant Array constructor

Issue: -

Description

Checks for the instantiation of array using redundant Array constructor. Autocorrect replaces to array literal which is the simplest and fastest.

Examples

# bad
Array.new([])
Array[]
Array([])
Array.new(['foo', 'foo', 'foo'])
Array['foo', 'foo', 'foo']
Array(['foo', 'foo', 'foo'])

# good
[]
['foo', 'foo', 'foo']
Array.new(3, 'foo')
Array.new(3) { 'foo' }

Further Reading