title: Ruby - what's the difference between single and double quotes?
body: <p>So I'm following this Ruby tutorial: <a href="http://ruby.learncodethehardway.org/book/ex16.html" rel="noreferrer">Learn Ruby the Hard Way.</a> </p>
  
  <p>In exercise 16 (linked above), you write a script that writes lines to a file. The relevant code is:</p>
  
  <pre><code>print "line 1: "; line1 = STDIN.gets.chomp()
  print "line 2: "; line2 = STDIN.gets.chomp()
  print "line 3: "; line3 = STDIN.gets.chomp()
  
  puts "I'm going to write these to the file."
  
  target.write(line1)
  target.write("\n")
  target.write(line2)
  target.write("\n")
  target.write(line3)
  target.write("\n")
  </code></pre>
  
  <p>However, being the lazy bum that I am, I originally typed in the example using single quotes in the last six lines, instead of the double quotes the tutorial tells you to use.</p>
  
  <p>This had an effect on the file. When I used single quotes, the file looked like this:</p>
  
  <pre><code>this is line 1\nthis is line 2\nthis is line 3
  </code></pre>
  
  <p>After switching those quotes to double-quotes, the file looked as expected:</p>
  
  <pre><code>this is line 1
  this is line 2
  this is line 3
  </code></pre>
  
  <p>Can someone tell me exactly why that is? Do single-quoted strings just ignore escape characters like <code>\n</code> or <code>\t</code>?</p>