Files and Text Processing
Formatting a Record
Build a readable record line from fields.
Formatting a Record
FormatRecord.scala
object Main {
def main(args: Array[String]): Unit = {
val qty =
val name = "widget"
val price = 5
val total = qty * price
val record = name + " x" + qty + " = " + total
println("record=" + record)
println("total=" + total)
}
}
object Main {
def main(args: Array[String]): Unit = {
val qty =
val name = "widget"
val price = 5
val total = qty * price
val record = name + " x" + qty + " = " + total
println("record=" + record)
println("total=" + total)
}
}
object Main {
def main(args: Array[String]): Unit = {
val qty =
val name = "widget"
val price = 5
val total = qty * price
val record = name + " x" + qty + " = " + total
println("record=" + record)
println("total=" + total)
}
}
format-record
Joining field values with text produces a formatted record string, the kind of line you would write to a report.