I frequently write something like this:
a_hash[\'x\'] ? a_hash[\'x\'] += \' some more text\' : a_hash[\'x\'] = \'first text\'
There ought to be
Since you are using the hash to collect strings, I assume you simply want to make sure that you don't get an error when appending. Therefore, I'd make the hash default the empty string. Then you can append without error, no matter the hash key.
a_hash = Hash.new {|h,k| h[k]=""}
texts = ['first text', ' some more text']
texts.each do |text|
a_hash['x'] << text
end
puts a_hash['x'] #=> 'first text some more text'