We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There are 2 extension to validate a valid string to reduce the ! in the if-condition block
!
fun String?.isNotNullOrEmpty(): Boolean = !this.isNullOrEmpty() fun String?.isNotNullOrBlank(): Boolean = !this.isNullOrBlank()
Even the validation result is true, the develop still has to add the fallback value
val name: String = if (name.isNotNullOrEmpty()) { name // 🚫 IDE error due Type mismatch. Required: String Found: String? }
The idea is building the extension with contract to tackle this issue
contract
fun String?.isNotNullOrEmpty(): Boolean { contract { returns(false) implies (this@isNotNullOrEmpty != null) } return !this.isNullOrEmpty() }
Reference:
Describe who will be the beneficiaries e.g. everyone, specific chapters, clients...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Why
There are 2 extension to validate a valid string to reduce the
!
in the if-condition blockEven the validation result is true, the develop still has to add the fallback value
The idea is building the extension with
contract
to tackle this issueReference:
Who Benefits?
Describe who will be the beneficiaries e.g. everyone, specific chapters, clients...
The text was updated successfully, but these errors were encountered: