Created
May 23, 2010 20:16
-
-
Save joelg/411214 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def hello(name) | |
puts "Hello #{name}" | |
end | |
hello("Joel") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure I would say they are "constant strings", but the difference between single-quoted strings and double-quoted strings is that you cannot do string interpolation - "hello $name" with single quotes, you must use concatenation - 'hello '.$name. I'm unsure about performance gains, I would doubt they could be at all significant, unless perhaps you had a VERY large loop! I like to use whatever is most readable, and often if variables are involved then it is double quotes.