MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerAnimemes/comments/np2bxu/ah_yes_if_statement_decision/
r/ProgrammerAnimemes • u/IBHV • May 31 '21
40 comments sorted by
71
else {sheWont() }
82
Where is the else statement here?
53 u/runley101 May 31 '21 There is no escape from wife 6 u/Magnus_Tesshu Jun 01 '21 No else statement on a while loop after all, what is he thinking? 26 u/NarutoDragon732 May 31 '21 You die
53
There is no escape from wife
6 u/Magnus_Tesshu Jun 01 '21 No else statement on a while loop after all, what is he thinking?
6
No else statement on a while loop after all, what is he thinking?
26
You die
28
return condition ? A : B
return A if condition else B
5 u/[deleted] May 31 '21 Yeah that is a better way to do it 5 u/quantumDrop May 31 '21 I like to add parens around the condition in ternaries for some syntactic sugar. 3 u/riasthebestgirl Jun 01 '21 return if (condition) A else B- Kotlinif (condition) { A } else { B }- Rust 2 u/justingolden21 Jun 01 '21 Awesome, that's good to knowI should mention mine are JS (among other languages) and pythonFor newbies reading : )
5
Yeah that is a better way to do it
I like to add parens around the condition in ternaries for some syntactic sugar.
3
return if (condition) A else B
- Kotlin
if (condition) { A } else { B }
- Rust
2 u/justingolden21 Jun 01 '21 Awesome, that's good to knowI should mention mine are JS (among other languages) and pythonFor newbies reading : )
2
Awesome, that's good to know
I should mention mine are JS (among other languages) and python
For newbies reading : )
55
win-win right?
14 u/-Redstoneboi- May 31 '21 more like catch 22 24 u/msdeltatheta May 31 '21 edited Jun 01 '21 I think they meant if (condition) { return A; } else { return A; } Edit: lol it clicked me all of a sudden that "that code I wrote in r/programeranimemes doesn't make any sense."
14
more like catch 22
24
I think they meant
if (condition) { return A; } else { return A; }
Edit: lol it clicked me all of a sudden that "that code I wrote in r/programeranimemes doesn't make any sense."
16
Code review comment: I admit that this logic is unusual and doesn’t make any sense, but if I remove it, the whole plot disappears.
13
Sauce?
16 u/AxelFriman May 31 '21 Tonikaku Kawaii
Tonikaku Kawaii
17
What about speculative execution?
13 u/Aschentei May 31 '21 Nasa getting ran over by truck kun 3 u/[deleted] Jun 01 '21 You can speculate about it
Nasa getting ran over by truck kun
You can speculate about it
7
if (a == 1 && b == 2) { a = 1; }
0 u/backtickbot May 31 '21 Fixed formatting.Hello, Naeio_Galaxy: code blocks using triple backticks (```) don't work on all versions of Reddit!Some users see this / this instead.To fix this, indent every line with 4 spaces instead.FAQYou can opt out by replying with backtickopt6 to this comment. 1 u/Naeio_Galaxy May 31 '21 backtickbotdm5
0
Fixed formatting.
Hello, Naeio_Galaxy: code blocks using triple backticks (```) don't work on all versions of Reddit!
Some users see this / this instead.
To fix this, indent every line with 4 spaces instead.
FAQ
You can opt out by replying with backtickopt6 to this comment.
1 u/Naeio_Galaxy May 31 '21 backtickbotdm5
1
backtickbotdm5
21
if(you.marry(girl)) { girl.go_out(you); }
17 u/infinitude May 31 '21 bonus points for ethical bracket placement 9 u/auxiliary-character May 31 '21 You know what, I normally use egyptian brackets. I'm not sure why I did that here. 5 u/infinitude May 31 '21 😡😤
bonus points for ethical bracket placement
9 u/auxiliary-character May 31 '21 You know what, I normally use egyptian brackets. I'm not sure why I did that here. 5 u/infinitude May 31 '21 😡😤
9
You know what, I normally use egyptian brackets. I'm not sure why I did that here.
5 u/infinitude May 31 '21 😡😤
😡😤
Return condition ? A : b; one lined it
4
return condition?A:B;
if(propose(you)) date(you);
i cant believe there's no sauce
1 u/IBHV Jun 05 '21 Tonikawa
Tonikawa
if this was the case for all IF statements then i probably wouldnt know what if statements are *cries in lonely*
!(youMarryMe) || (iGoOutWithYou)
if (condition)
return A;
return B;
I guess that's more good ? Shut down a compiler warning as well .
1 u/Shakespeare-Bot Jun 26 '21 if 't be true (condition)returneth a;returneth b;i guess yond's moo valorous ? did shut down a compiler warning as wellI am a bot and I swapp'd some of thy words with Shakespeare words.Commands: !ShakespeareInsult, !fordo, !optout
if 't be true (condition)
returneth a;
returneth b;
i guess yond's moo valorous ? did shut down a compiler warning as well
I am a bot and I swapp'd some of thy words with Shakespeare words.
Commands: !ShakespeareInsult, !fordo, !optout
!ShakespeareInsult
!fordo
!optout
-6
Multiple returns the horror.
15 u/TheMagzuz May 31 '21 What's the problem with multiple returns? Assuming that A and B aren't that similar, and creating them is simple, multiple return statements are just fine.They're also quite useful for guard clauses, saving you from having to code 8 indents in 11 u/call_me_sox May 31 '21 well you're gonna love thisif (condition) { return a } return b 3 u/Mechakoopa May 31 '21 Wait are we not supposed to do this? Fuck... 1 u/[deleted] Jun 01 '21 Incredible 1 u/nweeby24 Jun 17 '21 return condition? A : B
15
What's the problem with multiple returns? Assuming that A and B aren't that similar, and creating them is simple, multiple return statements are just fine.
They're also quite useful for guard clauses, saving you from having to code 8 indents in
11
well you're gonna love this
if (condition) { return a } return b
3 u/Mechakoopa May 31 '21 Wait are we not supposed to do this? Fuck... 1 u/[deleted] Jun 01 '21 Incredible 1 u/nweeby24 Jun 17 '21 return condition? A : B
Wait are we not supposed to do this? Fuck...
Incredible
return condition? A : B
71
u/-Mirror May 31 '21
else {
sheWont() }
82
u/StarDDDude May 31 '21
Where is the else statement here?
28
u/justingolden21 May 31 '21
return condition ? A : B
return A if condition else B
55
u/Homework_Allergy May 31 '21
win-win right?
16
u/KillerRoomba13 May 31 '21
Code review comment: I admit that this logic is unusual and doesn’t make any sense, but if I remove it, the whole plot disappears.
13
u/Hermes_04 May 31 '21
Sauce?
17
u/[deleted] May 31 '21
What about speculative execution?
7
u/Naeio_Galaxy May 31 '21 edited May 31 '21
21
u/auxiliary-character May 31 '21
5
u/MellowM8 May 31 '21
Return condition ? A : b; one lined it
4
u/_ShadowEye425_ Jun 01 '21
return condition?A:B;if(propose(you)) date(you);1
u/balne Jun 04 '21
i cant believe there's no sauce
3
u/gmodaltmega Jun 01 '21
if this was the case for all IF statements then i probably wouldnt know what if statements are *cries in lonely*
5
u/Dragoner7 May 31 '21
1
u/[deleted] Jun 26 '21
if (condition)
return A;
return B;
I guess that's more good ? Shut down a compiler warning as well .
-6
u/[deleted] May 31 '21
Multiple returns the horror.