What exactly is the difference? I used elsif right now, and it worked fine, and then added some stuff and changed it to else if just for the sake of making it look nicer, imo. The first returned no errors, the second caused the script to hang, and a syntax error requiring an extra end.
So, like I said. What exactly is the difference of elsif and else if?
This statement doesn't work in Ruby:
That's because the second "else" is a new block and requires another end to close it. With proper indentation, it would look like this:
if X
else if Y
else
end
end
Or:
if X
else
if Y
else
end
end
The difference is that you can easily chain multiple elsifs.
if X
elsif Y
elsif Z
elsif W
elsif U
end
It's easier to overview even though it is the same as this one:
if X
else
if Y
else
if Z
else
if W
else
if U
else
end
end
end
end
end
Oh okay, so it's just something to make scripting easier?
Yeah, pretty much.