If you use a conditional expression for a key, you get a fairly readable syntax and, at most, you need to remove only one item from Hash.
product_name = false extra_name = false user_information = { 'fname' => 'hello world', product_name ? :mmerge1 : nil => 'Product X', extra_name ? :xmerge1 : nil => 'Extra X' } user_information.delete nil p user_information
source share