반응형
배열 배열을 평면화하는 방법-끝까지 내려 가지는 않음
이것을 변환하는 가장 좋은 방법은 무엇입니까
[[["Club three Team one", 7800], ["Club three Team two", 7801]], [], [["Club four Team one", 7807], ["Club four Team two", 7808]], []]
으로
[["Club three Team one", 7800], ["Club three Team two", 7801], ["Club four Team one", 7807], ["Club four Team two", 7808]]
루비? flatten은 이것을 다음으로 변환합니다.
["Club three Team one", 7303, "Club three Team two", 7304, "Club four Team one", 7310, "Club four Team two", 7311]
http://apidock.com/ruby/Array/flatten 사용flatten(1)
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]]
반응형
'Nice programing' 카테고리의 다른 글
ASP.NET / PHP의 주류 Java 대안은 무엇입니까? (0) | 2020.12.04 |
---|---|
IntelliJ IDEA-캐럿 동작 (0) | 2020.12.04 |
Lisp 주석 규칙 (0) | 2020.12.04 |
SQL Server의 모든 현재 임시 테이블 목록을 가져 오는 방법이 있습니까? (0) | 2020.12.04 |
GCC가 바쁜 대기 루프를 최적화하지 못하게하는 방법은 무엇입니까? (0) | 2020.12.04 |