Created
September 20, 2022 22:23
-
-
Save s1monw1/db2c0558fc577bc7ea4ee0a81d01c8fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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