Skip to content

feat: improve Standard.kt#42

Merged
Water-OR merged 2 commits intomainfrom
feat/improve-standard
Jul 14, 2025
Merged

feat: improve Standard.kt#42
Water-OR merged 2 commits intomainfrom
feat/improve-standard

Conversation

@Water-OR
Copy link
Owner

@Water-OR Water-OR commented Jul 14, 2025

New Methods added to Standard.kt

Any?.isNull(): Boolean

  • Map null to true, otherwise false

Any?.notNull(): Boolean

  • Map null to false, otherwise true

Note

This method is an inverse version of Any.isNull(): Boolean

Any?.invNull(): Unit?

  • Map null to Unit, otherwise null (Invert nullability but lose the reference infomation)

<R> Any?.onNull(action: ()->R): R

  • Map null to invokation result of action, otherwise null

<T : Any> T?.mapNull(action: ()->T): T

  • Map null to invokation result of action, otherwise the receiver object

<R> Any?.then(action: ()->R): R

  • Return invokation result of action

Boolean.takeT(): Boolean?

  • Map false to null, otherwise true

Boolean.takeF(): Boolean?

  • Map true to null, otherwise false

Note

This method is an inverse version of Boolean.takeT(): Boolean?

@Water-OR Water-OR merged commit 172ee65 into main Jul 14, 2025
2 checks passed
@Water-OR Water-OR deleted the feat/improve-standard branch July 14, 2025 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant