Scala - Using String interpolation on object properties Code Example

The code for Using String interpolation on object properties

println("Using String interpolation on object properties")

case class Mobile(company: String, model: String)
val myMobile: Mobile = Mobile("Apple", "iPhone 13 Pro Max")
println(s"My favorite Mobile's Company = ${myMobile.company}, Model = ${myMobile.model}")

/*
Output:
Using String interpolation on object properties
My favorite Mobile's Company = Apple, Model = iPhone 13 Pro Max
*/
Code by IncludeHelp, on August 8, 2022 03:10

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.