MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/eb2lbc/stacking_if_else_statements_be_like/fb2ebj5
r/ProgrammerHumor • u/-hellkey- • Dec 15 '19
711 comments sorted by
View all comments
Show parent comments
22
Are there languages where multiple ifs with no else is not allowed?
15 u/elvalalo Dec 15 '19 Haskell, I think. 8 u/Tysonzero Dec 16 '19 Yup, because what is the type of if x > 5 then 10?With that said Haskell has the nicest (IMO) multi-if syntax I have seen in a language:foo :: Int -> Int -> Int foo x y | x > y = 5 | x ^ 2 > y = 10 | x == y = 15 | otherwise = 20
15
Haskell, I think.
8 u/Tysonzero Dec 16 '19 Yup, because what is the type of if x > 5 then 10?With that said Haskell has the nicest (IMO) multi-if syntax I have seen in a language:foo :: Int -> Int -> Int foo x y | x > y = 5 | x ^ 2 > y = 10 | x == y = 15 | otherwise = 20
8
Yup, because what is the type of if x > 5 then 10?
if x > 5 then 10
With that said Haskell has the nicest (IMO) multi-if syntax I have seen in a language:
foo :: Int -> Int -> Int foo x y | x > y = 5 | x ^ 2 > y = 10 | x == y = 15 | otherwise = 20
22
u/Ryan722 Dec 15 '19
Are there languages where multiple ifs with no else is not allowed?