string
またはarray
の中に入力があります。hash
に入力される可能性があります。ハッシュ内の配列から最後の値にアクセス
しかし、
Hash
は再帰的である可能性があります。Array
は複数の値を持つことができます。
例;
# ex.1 "name must be a string"
# ex.2 {"name"=>["name must be a string"]}
# ex.3 {"name"=>["name must be a string", "name must be greater than 3"]}
# ex.4 {"payment"=> {"currency"=>["currency must be a jpy"]}}
# ex.5 {"payment"=> {"currency"=>["currency must be a jpy", "currency must be string"]}}
文字列または配列内の最後の値のそれぞれをレンダリングしたいと思います。
# ex.1 method(x) => "name must be a string"
# ex.2 method(x) => "name must be a string"
# ex.3 method(x) => "name must be a string"/ "name must be greater than 3"
# ex.4 method(x) => "currency must be a jpy"
# ex.5 method(x) => "currency must be a jpy"/ "currency must be string"
をそれを投稿してください '{1 => {2 => [3,4]、3 => [5、 6]} '? '{1 => {2 => [[4,5]、{6 => 7}]}}'の場合は? –
[3,4,5,6]が返されます。 – Tosh
私は深い反復配列とハッシュhttps://github.com/am-kantox/iteraptorのための小さなライブラリを作成しました - あなたはそれがインスピレーションのためのコードを確認したいかもしれません。 – mudasobwa