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..