I have a method that is given a particular options hash like this
def send_params(options = {})
#Create string of some values in the hash.
end
I want to create a string with some of the values are in the hash. Particularly I am looking for the keys :key1, :key2, :key3, :key4 to create a string with their correspondent values. So, if my hash is like this:
{:key1 => 'value1', :key2 => 'value2', :key3 => 'value3', :key4 => 'value4', , :key5 => 'value5'}
I want to be able to create a string like:
'value1,value2|value3,value4'
And have the remaining hash as:
{:key5 => 'value5'}
So, the values that are found should be deleted from the hash. What is a good way of doing so?
Hash#deletemay be what you are looking for.It will remove a key/value pair from a hash and return the value.
Example: