document.write("<div class=\"pastie\">\n");
document.write("  <link href=\"http://pastie.org/stylesheets/embed.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n");
document.write("  <link href=\"http://pastie.org/stylesheets/clean.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n");
document.write("  \n");
document.write("\n");
document.write("  \n");
document.write("  \n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("	\n");
document.write("	<div class=\"allcode\">\n");
document.write("		<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
document.write("		<tr>\n");
document.write("			<td>\n");
document.write("				\n");
document.write("				<pre class=\"textmate-source-numbers\">1\n");
document.write("2\n");
document.write("3\n");
document.write("4\n");
document.write("5\n");
document.write("6\n");
document.write("7\n");
document.write("8\n");
document.write("9\n");
document.write("10\n");
document.write("11\n");
document.write("12\n");
document.write("13\n");
document.write("14\n");
document.write("15\n");
document.write("16\n");
document.write("17\n");
document.write("18\n");
document.write("19\n");
document.write("20\n");
document.write("21\n");
document.write("22\n");
document.write("23\n");
document.write("24\n");
document.write("25\n");
document.write("<\/pre>\n");
document.write("			<\/td>\n");
document.write("		<td>\n");
document.write("		<pre class=\"textmate-source\"><pre class=\"sunburst\"><span class=\'meta meta_require meta_require_ruby\'><span class=\'keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby\'>require<\/span> <span class=\'string string_quoted string_quoted_single string_quoted_single_ruby\'>\'set\'<\/span><\/span>\n");
document.write("\n");
document.write("<span class=\'meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby\'><span class=\'keyword keyword_control keyword_control_def keyword_control_def_ruby\'>def<\/span> <span class=\'entity entity_name entity_name_function entity_name_function_ruby\'>merge_hashes<\/span>(<span class=\'variable variable_parameter variable_parameter_function variable_parameter_function_ruby\'>first, second<\/span>)<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>  #The new hash has the keys of both hashes combined.<\/span>\n");
document.write("  keys <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> <span class=\'support support_class support_class_ruby\'>Set<\/span>.<span class=\'keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby\'>new<\/span>(first.keys.concat(second.keys))\n");
document.write("  result_hash <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> {}\n");
document.write("  keys.each <span class=\'keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby\'>do <\/span>|<span class=\'variable variable_other variable_other_block variable_other_block_ruby\'>k<\/span>|\n");
document.write("    first_value <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> first[k]\n");
document.write("    second_value <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> second[k]\n");
document.write("    <span class=\'keyword keyword_control keyword_control_ruby\'>if<\/span> first_value.is_a? <span class=\'variable variable_other variable_other_constant variable_other_constant_ruby\'>Hash<\/span> <span class=\'keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby\'>and<\/span> second_value.is_a? <span class=\'variable variable_other variable_other_constant variable_other_constant_ruby\'>Hash<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>      #when they are both hashes we will recursively merge_hash<\/span>\n");
document.write("      result_hash[k] <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> merge_hashes first_value, second_value\n");
document.write("    <span class=\'keyword keyword_control keyword_control_ruby\'>elsif<\/span> first_value <span class=\'keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby\'>==<\/span> <span class=\'constant constant_language constant_language_ruby\'>nil<\/span> <span class=\'keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby\'>or<\/span> second_value <span class=\'keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby\'>==<\/span> <span class=\'constant constant_language constant_language_ruby\'>nil<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>      #when one of them is nil, we only have one value<\/span>\n");
document.write("      result_hash[k] <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> first_value <span class=\'keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby\'>||<\/span> second_value\n");
document.write("    <span class=\'keyword keyword_control keyword_control_ruby\'>elsif<\/span> first_value.is_a? <span class=\'variable variable_other variable_other_constant variable_other_constant_ruby\'>Array<\/span> <span class=\'keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby\'>or<\/span> second_value.is_a? <span class=\'variable variable_other variable_other_constant variable_other_constant_ruby\'>Array<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>      #when one or both are an array, we concatenate them<\/span>\n");
document.write("      result_hash[k] <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> first_value.to_a.concat(second_value.to_a)\n");
document.write("    <span class=\'keyword keyword_control keyword_control_ruby\'>else<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>      #when they both have a value we make an array containing them<\/span>\n");
document.write("      result_hash[k] <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span> [first_value, second_value]\n");
document.write("    <span class=\'keyword keyword_control keyword_control_ruby\'>end<\/span>\n");
document.write("  <span class=\'keyword keyword_control keyword_control_ruby\'>end<\/span>\n");
document.write("  result_hash\n");
document.write("<span class=\'keyword keyword_control keyword_control_ruby\'>end<\/span>\n");
document.write("<\/pre><\/pre>\n");
document.write("		<\/td>\n");
document.write("		<\/tr>\n");
document.write("		<\/table>\n");
document.write("	\n");
document.write("	<\/div>\n");
document.write("\n");
document.write("\n");
document.write("<hr />\n");
document.write("<h2>result: <\/h2>\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("	\n");
document.write("	<div class=\"allcode\">\n");
document.write("		<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
document.write("		<tr>\n");
document.write("			<td>\n");
document.write("				\n");
document.write("				<pre class=\"textmate-source-numbers\">1\n");
document.write("2\n");
document.write("3\n");
document.write("4\n");
document.write("<\/pre>\n");
document.write("			<\/td>\n");
document.write("		<td>\n");
document.write("		<pre class=\"textmate-source\"><pre class=\"sunburst\">a<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span>{<span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;a&quot;<\/span>=&gt;{<span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;b&quot;<\/span>=&gt;[<span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;c&quot;<\/span>]}}\n");
document.write("b<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span>{<span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;a&quot;<\/span>=&gt;{<span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;b&quot;<\/span>=&gt;[<span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;e&quot;<\/span>]}}\n");
document.write("merge_hashes(a,b)\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>#=&gt; {&quot;a&quot;=&gt;{&quot;b&quot;=&gt;[&quot;c&quot;, &quot;e&quot;]}}<\/span>\n");
document.write("<\/pre><\/pre>\n");
document.write("		<\/td>\n");
document.write("		<\/tr>\n");
document.write("		<\/table>\n");
document.write("	\n");
document.write("	<\/div>\n");
document.write("\n");
document.write("\n");
document.write("  \n");
document.write("  \n");
document.write("  <div class=\"credit\">\n");
document.write("    <div class=\"buttons\">\n");
document.write("      <a href=\"http://pastie.org/pastes/866741.txt\">\n");
document.write("      <img src=\"http://pastie.org/images/view.png\" height=\"20\" width=\"67\" /><\/a>\n");
document.write("    <\/div>\n");
document.write("  \n");
document.write("    <a href=\"http://pastie.org/866741\">Pastie #866741<\/a> linked directly from <a href=\"http://pastie.org/\">Pastie<\/a>.\n");
document.write("  <\/div><\/div>");
