Moving key/value pair from one Hash to another

I am a newbie programmer using Ruby, and this is my first question on Stack Overflow so please bear with me. Let's say I have two Hashes:

hash_one = { :key1 => :value1, :key2 => :value2, :key3 => :value3 } 
hash_two = { :key4 => :value4, :key5 => :value5, :key6 => :value6 }

What would be the easiest way to move a key/value pair from hash_one (e.g. :key1 => :value1) into hash_two?


hash_two[:key1] = hash_one.delete(:key1)

delete removes key1 from hash_one and returns the value of key1. That value is taken as the parameter to set this key in hash_two.

Need Your Help

FindControl returning wrong control?


I ran into a situation where FindControl was returning a control that wasn't a complete match of the Id I was searching by. There are two controls in the parentcontrol with similar Ids like: "MyCo...

Java Swing: Setting a JTextArea to Null After Method

java swing jtextarea

I am creating my first GUI and I've run into a problem I can't seem to overcome. After executing a method by a button press, I want to set a JTextArea to "" or null. At the minute when the button is