From: Todd Benson Date: 2007-06-19T04:07:47+09:00 Subject: Re: Adding new value (in array) to existing key in a hash On 6/18/07, Todd Benson wrote: > class Array > def up; map {|i| i+1}; end > def down; map {|i| i-1}; end > end > h = { "a" => [[0,0],[3,4]], "b" => [[1,1],[9,8]], "c" => [[7,6],[4,5]] } > a = [] > h.each_value {|v| v.each {|coord| a << coord}} > end ^^^ delete the accidental "end" here > sorted = a.select {|coord| a.include?(coord.up) || > a.include?(coord.down) )}.sort > > p sorted sorry 'bout that