mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
730 B
29 lines
730 B
2 years ago
|
# Max Num
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
Write a function called `maxNum()` that takes three integers as arguments and returns the maximum number of the three.
|
||
|
|
||
|
### Ternary operators
|
||
|
|
||
|
One can do different things with ternary operators. It comes handy when one wants to do actions based on some condition.
|
||
|
This operation also keeps less amount of code, and hopefully more readable.
|
||
|
|
||
|
Typical form of the ternary operator is:
|
||
|
|
||
|
```
|
||
|
condition ? (value for true condition) : (value for false condition)
|
||
|
```
|
||
|
|
||
|
```dart
|
||
|
bool four_greater_than_five = 4 > 5 ? true : false;
|
||
|
```
|
||
|
|
||
|
- Note: The same could be achieved with simple if and else, but this approach reduces code length.
|
||
|
|
||
|
### Usage
|
||
|
|
||
|
```dart
|
||
|
int maxNum(int first, int second, int third) {...}
|
||
|
```
|