Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

What is the difference between "Else" and "Else If?"

Asked by 8 days ago

I'm not sure what the difference is, can someone explain?

2 answers

Log in to vote
1
Answered by 8 days ago
Edited 8 days ago

think of it like this: say your about to send someone at the store to buy you some games, and you tell them this: if there's Fortnite then then buy it, else if there's not fortnite but there's GTA 5 then buy the GTA 5 else just buy a carton of milk.

notice here, the first if indicates the preferred choice(in the example being buy Fortnite, the else if is the second preferred case if the first case cannot be satisfied(in the example being buying GTA), the else is basically the last resort if any of the previous cases cannot be met.

another example:

if Jailbreak is better than Mad City then

Play(Jailbreak)

elseif MadCity:HasMoreContentThan(Jailbreak) then

Play(Mad City)

elseif MadCity == Jailbreak then

Play(Jailbreak)

else

print("There's no fun games on roblox")

end

put the emphasis on the fact that you can have multiple elseifs

0
i tried this and it said fortnite doesnt exist (joke) TTChaos 200 — 8d
0
wow, really good explanation, thanks dude. SheepeySheeps 4 — 8d
Ad
Log in to vote
0
Answered by
TTChaos 200 Moderation Voter
8 days ago

elseif (not else if) should be used when you want another condition before running code else should be used when you don't want another condition before running code

Answer this question