Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Blocks Blocks Practice Build a Monster Class: Part 1

Andy Saini
Andy Saini
5,287 Points

Although a single quote wrapped string is faster, why does Jason use double quotes wrapped strings in all his videos?

Due to string extrapolation, a single quote wrapped string is supposed to be faster than the double quote wrapped counterpart. Why does Jason use the latter in all the videos?

2 Answers

rdaniels
rdaniels
27,258 Points

True, single quotes for names can suffice. Just as long as you're aware that the possible error might occur, and know how to fix it. : ) Happy coding!

rdaniels
rdaniels
27,258 Points

I always use double quotes. Using single quotes can sometimes return unwanted results, such as when your string has an apostrophe in it. Then you would need to add a back-slash before the apostrophe to tell the computer to ignore/accept the apostrophe. Using double quotes bypasses this problem and the computer interprets the string correctly. A lot of the teachers in these videos only use single quotes, but I see it as a bad practice. I always use double quotes for strings. Hope this helps!

Andy Saini
Andy Saini
5,287 Points

Ok for complex strings, but when using strings such as names, I think single quotes can suffice..