Updated Condition statement (markdown)

Bartłomiej Przemysław Pluta
2020-04-01 21:13:19 +02:00
parent fbc5cea463
commit 2e5c5fa5e4

@@ -6,7 +6,7 @@ The simplest form consists only of `if` keyword followed
by condition bounded on both sides with
parentheses (`(` and `)`) and statement
(or block of code):
```
```php
if (2 > 3) println("It gonna never be displayed!");
# or (using block of code)
@@ -17,7 +17,7 @@ if (2 > 3) {
```
Just like in Java condition **must be** of `bool` type.
```
```php
# Correct examples
if (true) println();
if (false) println();
@@ -40,7 +40,7 @@ You can use additional `else` clause which is always executed
when condition is resolved to `false`.
Example:
```
```php
if (2 > 3) println("It gonna never be displayed!");
else println("but this always will be displayed");
@@ -56,7 +56,7 @@ if (2 > 3) {
Remember that only one condition statement branch (`if` or `else`)
can be executed in single statement. There is no possibility
to execute both clauses:
```
```php
x = 1;
if (x > 0) {
@@ -85,7 +85,7 @@ nor evaluators related to this construction. It is just a combination
of `if` and `if-else` statements presented above.
Example:
```
```php
x = 3;
if (x == 0) {
println("x is zero");
@@ -122,7 +122,7 @@ if (x == 0) {
Thanks to its tree-like construction control flow falls through all conditions.
A branch first matched branch is executed
and following conditions are not checked anymore:
```
```php
x = 0
if (x == 1) {
println(); # Condition is resolved to false
@@ -141,8 +141,8 @@ It means that:
* in case of `A and B` expression, `B` expression will be evaluated only when `A` expression is evaluated to `true`
* in case of `A or B` expression, `B` expression will be evaluated only when `A` expression is evaluated to `false`.
It allows you for example to keep availability-check with actual condition togheter, for example:
```
It allows you for example to keep availability-check with actual condition together, for example:
```php
function test(x: string) {
# You are allowed to use following if-statement:
if(x.length >= 5 and x.charAt(4) == "o") {