How to smooth an array of arrays - but not completely down

What is the best way to convert this

[[["Club three Team one", 7800], ["Club three Team two", 7801]], [], [["Club four Team one", 7807], ["Club four Team two", 7808]], []] 

at

 [["Club three Team one", 7800], ["Club three Team two", 7801], ["Club four Team one", 7807], ["Club four Team two", 7808]] 

in ruby? flatten converts it all the way down

 ["Club three Team one", 7303, "Club three Team two", 7304, "Club four Team one", 7310, "Club four Team two", 7311] 
+49
ruby ruby-on-rails
Apr 10 2018-11-11T00:
source share
1 answer

use flatten(1) http://apidock.com/ruby/Array/flatten

 your_array = [[["Club three Team one", 7800], ["Club three Team two", 7801]], [], [["Club four Team one", 7807], ["Club four Team two", 7808]], []] your_array.flatten(1) #=> [["Club three Team one", 7800], ["Club three Team two", 7801], ["Club four Team one", 7807], ["Club four Team two", 7808]] 
+92
Apr 10 2018-11-11T00:
source share



All Articles