country =
[\"UK\", \"US\", \"RS\", \"EU\", \"UK\", \"US\"].
group_by{ |e| e }.
keep_if{ |_, e | e.length > 1 }
#⇒ {\"UK\"=>[\"UK\", \"UK\"], \"US\"=>[
By convention, underscore is used as a variable name for a value that is not used. Unlike other variable names, it can be used multiple times in a single parallel assignment.
In this particular case, the filter in the block is not interested in the key of the hash, but only the value of the hash, which is an array generated by group_by
.