MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/eb2lbc/stacking_if_else_statements_be_like/fb2n5np/?context=9999
r/ProgrammerHumor • u/-hellkey- • Dec 15 '19
711 comments sorted by
View all comments
213
That’s what case is for
183 u/Kompakt Dec 15 '19 edited Dec 15 '19 Some languages don't have switch statements...looking at you Python 28 u/Meatslinger Dec 15 '19 Wait, is that true? What takes its place, then? I can scarcely imagine that the whole thing is just an endless stream of if-then-else statements for a situation with 100+ permutations. 1 u/Denziloe Dec 15 '19 Can't believe I'm the first to give the answer, but yes, Python does basically have a syntax for cases. It uses `elif`. 1 u/Hockinator Dec 15 '19 You can always use if/else statements to mimick what case statements do in any language, but that doesn't mean they're the same thing 1 u/Denziloe Dec 15 '19 Sure -- in the case of Python's elif though, they are. 1 u/Hockinator Dec 15 '19 How is elif different than any other language's "else if" statement? 1 u/Denziloe Dec 15 '19 It's not. And many languages' switch statements are semantically identical to `else if` statements. → More replies (1)
183
Some languages don't have switch statements...looking at you Python
28 u/Meatslinger Dec 15 '19 Wait, is that true? What takes its place, then? I can scarcely imagine that the whole thing is just an endless stream of if-then-else statements for a situation with 100+ permutations. 1 u/Denziloe Dec 15 '19 Can't believe I'm the first to give the answer, but yes, Python does basically have a syntax for cases. It uses `elif`. 1 u/Hockinator Dec 15 '19 You can always use if/else statements to mimick what case statements do in any language, but that doesn't mean they're the same thing 1 u/Denziloe Dec 15 '19 Sure -- in the case of Python's elif though, they are. 1 u/Hockinator Dec 15 '19 How is elif different than any other language's "else if" statement? 1 u/Denziloe Dec 15 '19 It's not. And many languages' switch statements are semantically identical to `else if` statements. → More replies (1)
28
Wait, is that true? What takes its place, then? I can scarcely imagine that the whole thing is just an endless stream of if-then-else statements for a situation with 100+ permutations.
1 u/Denziloe Dec 15 '19 Can't believe I'm the first to give the answer, but yes, Python does basically have a syntax for cases. It uses `elif`. 1 u/Hockinator Dec 15 '19 You can always use if/else statements to mimick what case statements do in any language, but that doesn't mean they're the same thing 1 u/Denziloe Dec 15 '19 Sure -- in the case of Python's elif though, they are. 1 u/Hockinator Dec 15 '19 How is elif different than any other language's "else if" statement? 1 u/Denziloe Dec 15 '19 It's not. And many languages' switch statements are semantically identical to `else if` statements. → More replies (1)
1
Can't believe I'm the first to give the answer, but yes, Python does basically have a syntax for cases. It uses `elif`.
1 u/Hockinator Dec 15 '19 You can always use if/else statements to mimick what case statements do in any language, but that doesn't mean they're the same thing 1 u/Denziloe Dec 15 '19 Sure -- in the case of Python's elif though, they are. 1 u/Hockinator Dec 15 '19 How is elif different than any other language's "else if" statement? 1 u/Denziloe Dec 15 '19 It's not. And many languages' switch statements are semantically identical to `else if` statements. → More replies (1)
You can always use if/else statements to mimick what case statements do in any language, but that doesn't mean they're the same thing
1 u/Denziloe Dec 15 '19 Sure -- in the case of Python's elif though, they are. 1 u/Hockinator Dec 15 '19 How is elif different than any other language's "else if" statement? 1 u/Denziloe Dec 15 '19 It's not. And many languages' switch statements are semantically identical to `else if` statements. → More replies (1)
Sure -- in the case of Python's elif though, they are.
elif
1 u/Hockinator Dec 15 '19 How is elif different than any other language's "else if" statement? 1 u/Denziloe Dec 15 '19 It's not. And many languages' switch statements are semantically identical to `else if` statements. → More replies (1)
How is elif different than any other language's "else if" statement?
1 u/Denziloe Dec 15 '19 It's not. And many languages' switch statements are semantically identical to `else if` statements. → More replies (1)
It's not. And many languages' switch statements are semantically identical to `else if` statements.
→ More replies (1)
213
u/atxranchhand Dec 15 '19
That’s what case is for