Skip to content

Instantly share code, notes, and snippets.

@s1monw1
Created September 20, 2022 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s1monw1/db2c0558fc577bc7ea4ee0a81d01c8fd to your computer and use it in GitHub Desktop.
Save s1monw1/db2c0558fc577bc7ea4ee0a81d01c8fd to your computer and use it in GitHub Desktop.
@JvmInline
value class Password(val value: String)
@JvmInline
value class UserName(val value: String)
fun auth(userName: UserName, password: Password) {
println("authenticating $userName.")
}
fun main() {
auth(UserName("user1"), Password("12345"))
//does not compile due to type mismatch
auth(Password("12345"), UserName("user1"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment