Skip to content

Commit 47eb972

Browse files
committed
fragment-args-ktx: Remove default parameter implementations
1 parent ec4d0fb commit 47eb972

File tree

4 files changed

+161
-106
lines changed

4 files changed

+161
-106
lines changed

fragment-args-ktx/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## Unreleased
22

3+
### Changes
4+
5+
- **Breaking change!**
6+
Removed `default` parameters implementation from delegates to prevent mistakes when a value was not written before reading (#37).\
7+
`IllegalStateException` will be thrown by default if you're trying to read a value that wasn't written before.
8+
If you need to return the default value instead, specify the `default` parameter manually.
9+
- Added parameter `key: String` to `default` lambda.
10+
311
## [1.3.6-0] (2021-10-02)
412

513
### Changes

fragment-args-ktx/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,7 @@ val index by arguments.int { 1 }
8787
val index by arguments.int(default = { 1 })
8888
```
8989

90-
All delegates of non-nullable types have `default` implementation by default:
91-
- numeric primitives - `0`
92-
- boolean - `false`
93-
- String and CharSequence - `""` (empty string)
94-
- non-nullable arrays - empty array
95-
- non-nullable lists - empty list
96-
- Serializable and Parcelable - throw `IllegalStateException("No default value specified")`
90+
> If you've not implemented `default` parameter, reading a value that wasn't written before will throw `IllegalStateException`.
9791
9892
## Contributing
9993
Merge requests are welcome.

0 commit comments

Comments
 (0)