This post is the second in the series of “From JavaScript to Ruby”, which is aimed at helping JavaScript developers transition their thinking from JavaScript to Ruby. Here you’ll find a table of the ways we do things in JavaScript, and the way you’re supposed to do them in Ruby.
Style Guide
This post is a living document. Expect changes as necessary. Suggestions? Leave a comment below or email Josh.
Last updated: Apr 20, 2015
|
If you do this in JavaScript...
Airbnb |
...do it like this in Ruby
bbatsov |
|---|---|
| String quotes | |
'Some string' |
'Some string' |
| String concatenation | |
|
|
| Variable names | |
camelCaseVariable = true
|
camel_case_variable = false
|
| Tabs | |
|
|
| Callbacks | |
|
|
| Talking about methods | |
someClass.someMethod |
SomeClass#some_method |
| Comments | |
// single-line comment
|
# single-line comment
|
Like this post?
Share it with your followers
or
follow me on Twitter!