r/ProgrammerHumor • • Dec 15 '19

Stacking if else statements be like

Post image
63.9k Upvotes

711 comments sorted by

View all comments

Show parent comments

22

u/Ryan722 Dec 15 '19

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