How to flatten an array of arrays - but not all the way down

后端 未结 1 561
感动是毒
感动是毒 2020-12-25 09:24

What\'s the best way to convert this

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


        
相关标签:
1条回答
  • 2020-12-25 10:06

    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]]
    
    0 讨论(0)
提交回复
热议问题