From: Luc Heinrich Date: 2008-05-02T22:31:40+09:00 Subject: Re: Extracting a value from an array On 2 mai 08, at 15:05, Albert Schlef wrote: > I know I can change your "some_expression.first[:value]" to > "(some_expression || {}).first[:value]" and then things would work. > OK. > But I wondered if there's some nifty solution. How about this: content_type_header = lambda { |h| h[:name] == 'content-type' } content_type = headers.find(&content_type_header).fetch(:value) if headers.any?(&content_type_header) -- Luc Heinrich - luc@honk-honk.com