Skip to content

Snowflake

MerlinTHS edited this page Feb 17, 2023 · 3 revisions

Please try to use the Compiler Plugin instead!

In situations where you don't want to define a new property for checking and unwrapping via delegation, you can use the Snowflake - property instead. Simply add a snowflake to the expression to validate.

import com.github.merlinths.io.validator.*
import java.util.Optional

fun main() = kava {
    val processedMagic = process(getNumber().`*`)

    println("Processed magic number is $processedMagic")
}

fun process(number: Int) =
    number * 10 + 5

fun getNumber() =
    Optional.of(42)

Clone this wiki locally