Welcome to Giant Robots Smashing Into Other Giant Robots — a weblog about development, business, design and technology — written by thoughtbot.

uno o dos

Now in Ruby, strings can be created using single or double quotes. The only difference is that you can interpolate variables in double quoted strings. I constantly see the following confusing code:

1
2
3
user.name = "name"

link_to "home", root_path

Here we’re using double quoted strings, but there’s no interpolation. As soon as I see double quotes, I think there’s going to be some interpolation. Using double quotes without interpolation is flat out wrong. The above code is more correct, and much less confusing using single quotes.

1
2
3
user.name = 'name'

link_to 'home', root_path

This may not seem like much, but it makes a huge difference when followed consistently.


About this entry

 

thoughtbot is hiring

We are hiring web developers and web designers in both Boston and New York, NY.

What are we up to?

We built Shoulda, an eclectic set of additions to Test::Unit; Paperclip to manage uploaded files without hassle; Jester, a REST/ActiveResource client library written in Javascript, and Squirrel, an enhancement for ActiveRecord's find syntax; — amongst some other projects.

Chad (President) and Jon (CTO) co-authored a technical book titled Pro Active Record: Databases with Ruby and Rails, which explores the ins and outs of the ActiveRecord ruby library. You can buy it today at Amazon.com.

About thoughtbot, inc.

We are a small web application development consulting business, with offices in Boston, MA and New York, NY. If you're looking to find a team for your next web development project or your new web application — get in touch.