Assign key and value pair to a string in hash each method
hash = { "key1" => "val1", "key2" => "val2" } string = "" hash.each { |k,v| string << "#{k} is #{v}\n" } puts string