Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:34+00:00 2026-05-23T15:58:34+00:00

If I had a complex if statement that I did not want to overflow

  • 0

If I had a complex if statement that I did not want to overflow simply for aesthetic purposes, what would be the most kosher way to break it up since coffeescript will interpret returns as the body of the statement in this case?

if (foo is bar.data.stuff and foo isnt bar.data.otherstuff) or (not foo and not bar)
  awesome sauce
else lame sauce
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:58:35+00:00Added an answer on May 23, 2026 at 3:58 pm

    CoffeeScript will not interpret the next line as the body of the statement if the line ends with an operator, so this is ok:

    # OK!
    if a and
    not 
    b
      c()
    

    it compiles to

    if (a && !b) {
      c();
    }
    

    so your if could be formatted as

    # OK!
    if (foo is 
    bar.data.stuff and 
    foo isnt bar.data.otherstuff) or 
    (not foo and not bar)
      awesome sauce
    else lame sauce
    

    or any other line-breaking scheme so long as the lines end in and or or or is or == or not or some such operator

    As to indentation, you can indent the non-first lines of your if so long as the body is even more indented:

    # OK!
    if (foo is 
      bar.data.stuff and 
      foo isnt bar.data.otherstuff) or 
      (not foo and not bar)
        awesome sauce
    else lame sauce
    

    What you cannot do is this:

    # BAD
    if (foo  #doesn't end on operator!
      is bar.data.stuff and 
      foo isnt bar.data.otherstuff) or 
      (not foo and not bar)
        awesome sauce
    else lame sauce
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a discussion with some colleagues mentioning that there are not too many
Okay, little oddity I discovered with my C++ compiler. I had a not-overly complex
This is not an original problem. I had a complex problem which is now
I had to break my too complex project, about 100files, to small files. A
Had a page that was working fine. Only change I made was to add
Had a good search here but can't see anything that gets my mind in
I had to delete all the rows from a log table that contained about
Had a problem in a complex linq query so I simplified it in LINQPad:
I've had to create a custom model binder to bind data for a complex
Would it be possible to alias an expression returned by a SELECT statement in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.