How to join a string by line endings in Ruby <p>I have an array of strings, which I wish to join by line ending:</p> <pre><code>a = ['first line', 'second line', 'third line'] </code></pre> <p>I want to join them in ruby in the most idiomatic way, using the OS default line ending, so that it would use <code>'\r\n'</code> to join the lines on windows and it would use <code>'\n'</code> to join the lines on *NIX. In python, I would do this:</p> <pre><code>os.linesep.join(a) </code></pre> <p>How would I do this idiomatically in ruby?</p>