Tiny types without value class
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
case class UserId(id: Int) | |
case class Username(name: String) | |
case class TweetId(id: Int) | |
case class TweetContent(content: String) | |
case class User(id: UserId, name: Username) | |
case class Tweet(id: TweetId, content: TweetContent) | |
object Test extends App { | |
val user = User(UserId(1), Username("kunal")) | |
val tweet = Tweet(TweetId(11), TweetContent("ABC")) | |
println("userID :-" + user.id) | |
println("tweetID:-" + tweet.content) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment