Jump to content

Conditional structures: Difference between revisions

Line 1,449:
}
fmt.Println("I'm off!")</lang>
 
=={{header|Harbour}}==
'''if-elseif-else-endif'''
<lang harbour>IF x == 1
SomeFunc1()
ELSEIF x == 2
SomeFunc2()
ELSE
SomeFunc()
ENDIF</lang>
 
'''do case'''
<lang harbour>DO CASE
CASE x == 1
SomeFunc1()
CASE x == 2
SomeFunc2()
OTHERWISE
SomeFunc()
ENDCASE</lang>
 
'''switch'''
While '''if-elseif-else-endif''' and '''do case''' constructions allows using of any expressions as conditions, the '''switch''' allows literals only in conditional '''case''' statements. The advantage of the '''switch''' command is that it is much faster.
<lang harbour>SWITCH x
CASE 1
SomeFunc1()
CASE 2
SomeFunc2()
OTHERWISE
SomeFunc()
END</lang>
 
=={{header|Haskell}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.