Project

General

Profile

Actions

Feature #12734

closed

`Array#flat?`

Added by sos4nt (Stefan Schüßler) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:77205]

Description

It might be useful to have a method that determines whether an array is flat, i.e. one-dimensional.

[1, 2, 3].flat?   #=> true
[1, [2, 3]].flat? #=> false

The result should be equivalent to ary == ary.flatten (without the overhead of actually flattening the array)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0