You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
if - The if statement is used to execute a block of code if a condition is true.
else if - The else if statement is used to execute a block if the condition is false and its condition is true.
else - The else statement is used to execute a block if all the conditions (if/else if) is false.
switch - The switch statement is used to execute a block of code depending on the value of a variable.
for - The for statement is used to execute a block of code a certain number of times.
while - The while statement is used to execute a block of code while a condition is true.
loop - The loop statement is used to execute a block of code until is breaked.
break - The break statement is used to break a loop.
All the control flow statements are expressions, so they can be used as values. (the last expression of the block will be the value of the expression)
All the syntaxes are subject to change. Until the first release.
The examples may be contain a unimplemented function, but they will be implemented in the future.
if/else if/else
This example shows how to use the if/else if/else statements.
~get_stage<age>{<
return if<lt<age><12>>{<
"You are a child"
>}
else if<lt<age><20>>{<
"You are a teenager"
>}
else{<
"You are an adult"
>};
>}
~main<argc><argv>{<
println<foo<10>>; // prints: You are a child
println<foo<19>>; // prints: You are a teenager
println<foo<30>>; // prints: You are an adult
>}
You can also print it directly:
~main<argc><argv>{<
age = 23;
println<
if<lt<age><12>>{<
"You are a child"
>}
else if<lt<age><20>>{<
"You are a teenager"
>}
else{<
"You are an adult"
>}
>;
>}
switch
SOON
for
SOON
while
This example shows how to use the while statement.
Controls Flow
In ocypode we will have this controls flow:
if
- Theif
statement is used to execute a block of code if a condition is true.else if
- Theelse if
statement is used to execute a block if the condition is false and its condition is true.else
- Theelse
statement is used to execute a block if all the conditions (if
/else if
) is false.switch
- Theswitch
statement is used to execute a block of code depending on the value of a variable.for
- Thefor
statement is used to execute a block of code a certain number of times.while
- Thewhile
statement is used to execute a block of code while a condition is true.loop
- Theloop
statement is used to execute a block of code until is breaked.break
- Thebreak
statement is used to break a loop.if
/else if
/else
This example shows how to use the
if
/else if
/else
statements.You can also print it directly:
switch
for
while
This example shows how to use the
while
statement.loop
/break
This example shows how to use the
loop
andbreak
statement.The text was updated successfully, but these errors were encountered: