From: Albert Schlef Date: 2008-05-02T23:24:41+09:00 Subject: Re: Extracting a value from an array Simon Krahnke wrote: > That's simply the wrong data structure for the task. > So the question is: why not use a Hash? (HTTP servers may return several headers having the same name, so I can't use a hash.) Luc Heinrich wrote: > Or, since you can pass a proc to the find method which > gets called when nothing is found, this: > > content_type = headers.find(lambda {Hash.new}) { > ... }.fetch(:value, nil) Luc, thanks. But I don't think it's more elegant than ".find { cond } || {}". Luc, tell me, why does find() accept this proc parameter? What is it useful for? Ok, I understand it calls it if no value found, but... we could do "|| expression" instead, couldn't we? Perhaps there is something here I miss? -- Posted via http://www.ruby-forum.com/.