Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Single and double quotes do differ in ruby (See related posts)

// description of your code here

my_string = 'This is mine!'
your_string = "This is yours!"
my_string += '\n\t\tAgain, I say!'
your_string += "\n\t\tAgain, I say!"
puts my_string
# => This is mine!\n\t\tAgain, I say!
puts your_string
# => This is yours!
# Again, I say!

r = 42
the_answer = "The answer is #{r}!"
# => "The answer is 42!"
the_answer = 'The answer is #{r}!'
# => "The answer is \#{r}!"



You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts