Search Results

Search found 1 results on 1 pages for 'avakar'.

Page 1/1 | 1 

  • What are the advantages of squashing assignment and error checking in one line?

    - by avakar
    This question is inspired by this question, which features the following code snippet. int s; if((s = foo()) == ERROR) print_error(); I find this style hard to read and prone to error (as the original question demonstrates -- it was prompted by missing parentheses around the assignment). I would instead write the following, which is actually shorter in terms of characters. int s = foo(); if(s == ERROR) print_error(); This is not the first time I've seen this idiom though, and I'm guessing there are reasons (perhaps historical) for it being so often used. What are those reasons?

    Read the article

1