2020-09-27 01:27:15 +03:00
|
|
|
## Extension Lambdas (#1)
|
|
|
|
|
|
|
|
Define the following functions so they behave the same as their standard
|
|
|
|
library counterparts:
|
|
|
|
|
|
|
|
- `createString()` behaves like `buildString()`. Start by creating a new
|
2020-12-12 02:30:51 +03:00
|
|
|
instance of `StringBuilder`, call the extension lambda argument on it, then
|
|
|
|
return the `String` result.
|
2020-09-27 01:27:15 +03:00
|
|
|
|
|
|
|
- `createList()` behaves like `buildList()`. This function has one generic
|
2020-12-12 02:30:51 +03:00
|
|
|
parameter. Create an `ArrayList<T>`, call the extension lambda argument on it,
|
|
|
|
and return a read-only `List`.
|
2020-09-27 01:27:15 +03:00
|
|
|
|
|
|
|
- `createMap()` behaves like `buildMap()`. This function has two generic
|
2020-12-12 02:30:51 +03:00
|
|
|
parameters. Create a `HashMap<K, V>`, call the extension lambda argument on
|
|
|
|
it, and return a read-only `Map`.
|
2020-09-27 01:27:15 +03:00
|
|
|
|
|
|
|
The code in `main()` tests your functions against the standard library
|
|
|
|
versions. Notice that `buildList()` and `buildMap()` infer their generic
|
2020-09-29 14:29:57 +03:00
|
|
|
parameters.
|
|
|
|
|
2020-10-12 13:11:53 +03:00
|
|
|
<sub> This task doesn't contain automatic tests,
|
|
|
|
so it's always marked as "Correct" when you run "Check".
|
|
|
|
Please compare your solution with the one provided! </sub>
|