Skip to content

Instantly share code, notes, and snippets.

@kunals201

kunals201/User.scala

Last active Aug 21, 2018
Embed
What would you like to do?
Tiny types without value class
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