resultの2次元配列になるようなsplit内のコードがわかりません。
ライブラリは使用しません。
[
{
:type=>"h1", :value=>1,
:children=>[{:type=>"p", :value=>2}]
},
{
:type=>"h2", :value=>3,
:children=> [
{
:type=>"p", :value=>4,
:children=>[
{:type=>"p", :value=>5},
{:type=>"h3", :value=>6}
],
},
{:type=>"p", :value=>7},
{
:type=>"h3", :value=>8,
:children=>[{:type=>"h3", :value=>9}]
}
]
},
{
:type=>"h2", :value=>11,
:children=>[{:type=>"p", :value=>10}]
}
]
def split(obj)
# Please this code
end
# result
[
["h1:1", "p:2"],
["h2:3", "p:4", "p:5" ],
["h3:6", "p:7"],
["h3:8"],
["h3:9"],
["h2:11", "p:10"],
]
result
の値はあっていますか? 特に元のリストでは異なる hash にいるh3:6
とp:7
が同じリストにいるのはどういう仕組みが想定されているのでしょうか。