Skip to content
New issue

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

[#50] As a developer, I can use String extensions in effective way #51

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

hoangnguyen92dn
Copy link
Collaborator

#50

What happened 👀

Add contract {} in these 2 extensions:

  • String?.isNotNullOrEmpty()
  • String?.isNotNullOrBlank()

Insight 📝

Explained the reason why we need to add contract {} in issue #50

Proof Of Work 📹

CI ✅

@hoangnguyen92dn hoangnguyen92dn requested a review from a team February 12, 2025 07:51
@hoangnguyen92dn hoangnguyen92dn self-assigned this Feb 12, 2025
@hoangnguyen92dn hoangnguyen92dn marked this pull request as draft February 12, 2025 08:22
@OptIn(ExperimentalContracts::class)
fun String?.isNotNullOrEmpty(): Boolean {
contract {
returns(false) implies (this@isNotNullOrEmpty != null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think returning true should implies that its not null, not false

Suggested change
returns(false) implies (this@isNotNullOrEmpty != null)
returns(true) implies (this@isNotNullOrEmpty != null)

@OptIn(ExperimentalContracts::class)
fun String?.isNotNullOrBlank(): Boolean {
contract {
returns(false) implies (this@isNotNullOrBlank != null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants