// Created on savesnippets.com · https://savesnippets.com/DJ4kYm7Ms4SOzx @JvmInline value class UserId(val raw: Long) @JvmInline value class PostId(val raw: Long) @JvmInline value class Email(val raw: String) { init { require(raw.contains("@")) { "not an email: $raw" } } val domain: String get() = raw.substringAfter("@") } fun deleteUser(id: UserId) { println("deleting user ${id.raw}") } fun main() { val u = UserId(42L) val p = PostId(99L) deleteUser(u) // ✓ // deleteUser(p) // ✗ compile error — different types // deleteUser(42L) // ✗ compile error — Long isn't UserId val e = Email("alice@example.com") println(e.domain) // example.com // At runtime, UserId is just a Long — zero memory overhead vs raw Long. }