Is there a nice (one line) way of writing a hash in ruby with some entry only there if a condition is fulfilled? I thought of
{:a => \'a\', :b => (\'b\
hash, hash_new = {:a => ['a', true], :b => ['b', false]}, {} hash.each_pair{|k,v| hash_new[k] = v[1] ? v : nil } puts hash_new