1
1
Fork 0
AtomicKotlinCourse/Usability/Destructuring Declarations/Exercise 1/task.md

17 lines
560 B
Markdown
Raw Normal View History

## Destructuring Declarations (#1)
Using `Pairs.kt` as a model, write a function `calculate(n1: Int, n2: Int)`
which returns a `Triple` containing a `Boolean` and two `Int`s. If either `n1`
or `n2` is less than zero, it returns a `Triple` containing `false` and two
zeros. Otherwise, it returns a `Triple` containing:
2020-12-02 21:45:43 +03:00
+ `true`
2020-04-23 15:31:30 +03:00
2020-12-02 21:45:43 +03:00
+ The sum of `n1` and `n2`
2020-04-23 15:31:30 +03:00
2020-12-02 21:45:43 +03:00
+ `n1` multiplied by `n2`
The starter code contains a `main()` with tests, showing the difference between
unpacking the `Triple` using `first`, `second` and `third` versus a
destructuring declaration.