what would be the alternative? to always execute if the condition is true, but sometimes execute it even when false, for funsies?
Hey, I like a little chaos in my codebase 😆
const funsies = () => (Math.round(Math.random() * 1000) % 2 == 0) if ( condition || funsies() ) { // do the thing }is this AI?
Nope. I’m staunchly against “AI”. If the code sucks, it’s because I wrote bad code.
Edit: Oh, or did you mean is that how “AI” works?
The “only” part implies exclusivity, which may be false, because other things might run the code anyway.
IF “I can see the sun” THEN “It’s day.”
Nothing wrong about that. However if we make it exclusive:
IF AND ONLY IF “I can see the sun” THEN “It’s day.”
That’s obviously wrong. I can actually not keep the day away by sitting with closed eyes in my mothers basement with the curtains shut.
“Only if” might make sense in a legal contract, but there’s no way a piece of code can stop other pieces of code from calling the same functions.
Brb, making a truly “if” statement function in my products code base for funsies.
The boolean operator ‘If and only if’ do not have a relation with the program instruction ‘if’.
The programatic ‘if’ is a jump, not a boolean operator. It do not have truth table.
In logic:, if and iff can be seen like functions taking two booleans and returning a boolean
-
‘if a then b’ (noted a -> b): return true if a is false or b is true. Example: ‘if I eat pizza then I fart’ This is true even if I fart all the time (if b is true, we do not care about the value of a) as long as I fart when eating pizza (if a is true, b must be also true)
-
‘a <-> b’ is equivalent to ‘a -> b and b -> a’: the two should be true at the same time. I can only fart will eating pizza and cannot fart otherwise.
So in programming, you’d write ‘if’ as:
not pizza or fartwhere the farting is irrelevant until the pizza is involved.While ‘iff’ would be:
pizza equals fartwhere pizza means fart and no pizza means no fart.I actually wrote iff as
(not pizza and not fart) or (pizza and fart)before, and I’m pretty sure that’s the way I wrote an iff in production code in the past, but your comment made me realize that “they should be true at the same time” can be tested really easily with equality.I don’t love the pizza fart variable naming convention, but it’s better than foobar and I don’t have a better suggestion 😅
deleted by creator
-
Waiting for a programming language with
iffSyntaxI hope this memer is not a programmer or logician, but ideally neither.
If and only if… haha unless…
if ( test == false ) x = 1 else x != 1Reminds me of this fun stack exchange q
IFF you use the universal quantifier









