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

long long if's (how-to go about it) #1091

Open
determin1st opened this issue Jan 16, 2020 · 4 comments
Open

long long if's (how-to go about it) #1091

determin1st opened this issue Jan 16, 2020 · 4 comments

Comments

@determin1st
Copy link

determin1st commented Jan 16, 2020

For example, if you have some if:

if (typeof options.data == 'string') or (typeof! options.data == 'URLSearchParams')
  true

It's rather long and with more indenting inside some function function with tabs/spaces...
readability (of this line) should be broken, eventually..

On the other hand, having this javascript code:

if (typeof options.data === 'string' ||
    toString$.call(options.data).slice(8, -1) === 'URLSearchParams')
{
  true;
}

looks better, right?

So, the question is how to go about long if's, how to indent them, space them, multiline them (in livescript ofc) or this is not possible/resonable/smart enough etc?

@ceremcem
Copy link

ceremcem commented Jan 16, 2020

How about:

if (true or
    false) and
    false
    #----
    console.log "foo"
else
    console.log "bar"

@vendethiel
Copy link
Contributor

if typeof! options.data in <[String URLSearchParams]>

@determin1st
Copy link
Author

Great, will use both!

@anko
Copy link

anko commented Jan 18, 2020

You can use a backslash to ignore a newline:

if something? \
  or something-else?
  do-something!

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