Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the "switch" example have a space before the first paren? #134

Open
leoj3n opened this issue Jan 24, 2014 · 4 comments
Open

Should the "switch" example have a space before the first paren? #134

leoj3n opened this issue Jan 24, 2014 · 4 comments

Comments

@leoj3n
Copy link

leoj3n commented Jan 24, 2014

https://github.com/rwaldron/idiomatic.js#misc

Should it be written switch ( instead of the current switch(?

@jamsyoung
Copy link
Contributor

Yes, switch is not a function so it should have a space before the (. I am not a fan of inner-space, so I would write it as:

switch (foo) {

For those that do use inner-space:

switch ( foo ) {

@sopta
Copy link

sopta commented Jun 24, 2014

I don't think that inner-space give more readability in the switch statement.

@jcblw
Copy link

jcblw commented Jun 24, 2014

This is in-line with the way that functions are declared

var foo = function( bar ) {
}

switch( bar ) {
}

the style in which the switch is declared seems accurate to me.

@jamsyoung
Copy link
Contributor

switch is not a function, it is a statement, so it should have the space before the paren to make this clear. Also, practically every example I could find, outside of this instance, shows the space in front of the paren.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants