-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Else Statements | ||
|
||
It's great to be able to use an `if` statement to do something if a condition is `true`. | ||
But what about when a condition is false? | ||
|
||
That's where `else` (and `else if` statements come in!) | ||
|
||
Else statements allow us to provide a block of code for Jiki to run when the `if` statement's condition is false. | ||
|
||
<img src="https://assets.exercism.org/bootcamp/diagrams/else-statement-anatomy.png" class="diagram"/> | ||
|
||
So going back to Jiki functioning as a Robot-bouncer at a club, he could a `reject()` function to send someone away if they're not the right age (rather than just staring silently at them like he did before!) | ||
|
||
<img src="https://assets.exercism.org/bootcamp/diagrams/else-example.png" class="diagram"/> | ||
|
||
### Else if | ||
|
||
We can chain statements together using `else if`. | ||
And we can still have a final `else` on that too. | ||
|
||
<img src="https://assets.exercism.org/bootcamp/diagrams/else-if-statement-anatomy.png" class="diagram"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Functions that return | ||
|
||
As well as doing things, functions often return things back to Jiki. | ||
|
||
This isn't like printing to a screen, or outputting something. | ||
This is very specifically the function returning something to **Jiki** to use later. | ||
|
||
Image we have a `current_time` function that gives us the current time back out as a string. When Jiki uses it, he gets a string with the time on that he can then use: | ||
|
||
<img src="https://assets.exercism.org/bootcamp/diagrams/function-return-current-time.png" class="diagram"/> | ||
|
||
He could do various things with this, such as store it in a variable: | ||
|
||
<img src="https://assets.exercism.org/bootcamp/diagrams/function-return-store-current-time.png" class="diagram"/> | ||
|
||
This works exactly the same with functions that have inputs. | ||
Imagine a `join` function that takes two strings and joins them with a space in between: | ||
|
||
<img src="https://assets.exercism.org/bootcamp/diagrams/function-return-join.png" class="diagram"/> | ||
|
||
Just like before, we could ask Jiki to store the result in a variable: | ||
|
||
<img src="https://assets.exercism.org/bootcamp/diagrams/function-return-store-join.png" class="diagram"/> |