📜 ⬆️ ⬇️

About operators

Thought here over the question. In the C language for the operators && and || The order of evaluation of the operands is defined. Moreover, if the left operand returns false for && or true for ||, then the right operative will no longer be calculated. This allows you to use constructions of the type “smth or die”, which very often can be found in scripting languages:
(f = fopen ("file", "r")) || fprintf (stderr, "Can not open file \ n");
Have you ever seen such C code? Me not. I wonder why :) Anticipating the answers “too long”, “ugly”, etc.: then why is it so common in scripting languages?

')

Source: https://habr.com/ru/post/52531/


All Articles