minus-squaretunawasherepoo@iusearchlinux.fyitoProgrammer Humor@programming.dev•Me after I got firedlinkfedilinkarrow-up29·9 months ago__LINE__ returns the line of code its on, and % 10 means “remainder 10.” Examples: 1 % 10 == 1 ... 8 % 10 == 8 9 % 10 == 9 10 % 10 == 0 <-- loops back to 0 11 % 10 == 1 12 % 10 == 2 ... 19 % 10 == 9 20 % 10 == 0 21 % 10 == 1 In code, 0 means false and 1 (and 2, 3, 4, …) means true. So, if on line 10, you say: int dont_delete_database = true; then it will expand to: int dont_delete_database = ( 10 % 10 ); // 10 % 10 == 0 which means false // database dies... if you add a line before it, so that the code moves to line 11, then suddenly it works: // THIS COMMENT PREVENTS DATABASE FROM DYING int dont_delete_database = ( 11 % 10 ); // 11 % 10 == 1, which means true linkfedilink
tunawasherepoo@iusearchlinux.fyi to Programming@programming.dev · edit-21 year agodid git add . in subfolder 🤡plus-squaremessage-squaremessage-square3fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1message-squaredid git add . in subfolder 🤡plus-squaretunawasherepoo@iusearchlinux.fyi to Programming@programming.dev · edit-21 year agomessage-square3fedilink
__LINE__
returns the line of code its on, and% 10
means “remainder 10.” Examples:1 % 10 == 1 ... 8 % 10 == 8 9 % 10 == 9 10 % 10 == 0 <-- loops back to 0 11 % 10 == 1 12 % 10 == 2 ... 19 % 10 == 9 20 % 10 == 0 21 % 10 == 1
In code,
0
meansfalse
and1
(and2
,3
,4
, …) meanstrue
.So, if on line 10, you say:
int dont_delete_database = true;
then it will expand to:
int dont_delete_database = ( 10 % 10 ); // 10 % 10 == 0 which means false // database dies...
if you add a line before it, so that the code moves to line 11, then suddenly it works:
// THIS COMMENT PREVENTS DATABASE FROM DYING int dont_delete_database = ( 11 % 10 ); // 11 % 10 == 1, which means true