Skip to content

Instantly share code, notes, and snippets.

@shubhra02

shubhra02/TypeSafe.scala

Last active Jun 17, 2017
Embed
What would you like to do?
Type Safe Code
import com.typesafe.config._
case class Employee(config: Config) {
val jobTitle = config.getString("jobTitle")
object company {
val companyName = config.getString("company.companyName")
val place = config.getString("company.place")
}
}
val config = ConfigFactory.parseString(
"""
|se.typesafe.example {
| jobTitle = "Software consultant"
| company {
| companyName = "Knoldus"
| place = "Noida"
| }
|}
""".stripMargin
)
val employee = Employee(config.getConfig("se.typesafe.example"))
employee.jobTitle
// res0: String = Software consultant
employee.company.companyName
// res1: String = Knoldus
employee.company.place
// res2: String = Noida
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment