Suppose I have the hash{ "a" => "b", "c" => "d" } and I would like to transform it into the string "a=b\nc=d".
The solution I’ve come up with so far is
{ "a" => "b", "c" => "d" }.map { |k, v| k + "=" + v }.join("\n")
Is there a better/more elegant way? For example, can it be done using a single method call?
All so far proposed solutions look good to me. Here is an ‘unchained’ one: