[ruby-core:77309] [Ruby trunk Feature#12734] `Array#flat?`

From: mail@...
Date: 2016-09-19 07:00:23 UTC
List: ruby-core #77309
Issue #12734 has been updated by Stefan Schテシテ殕er.


Herwin W wrote:
> This is pretty trivial to implement yourself:

Oh, you're right. I didn't realize that this is merely a type check.

----------------------------------------
Feature #12734: `Array#flat?`
https://bugs.ruby-lang.org/issues/12734#change-60548

* Author: Stefan Schテシテ殕er
* Status: Feedback
* Priority: Normal
* Assignee: 
----------------------------------------
It might be useful to have a method that determines whether an array is flat, i.e. one-dimensional.

~~~ruby
[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)



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next