Build a readable record line from fields.

format-record Joining field values with text produces a formatted record string, the kind of line you would write to a report.

Formatting a Record

qty
FormatRecord.scala
Replay: real traced execution (multi-file project)
object Main {
  def main(args: Array[String]): Unit = {
    val qty = 3
    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 = 1
    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 = 10
    val name = "widget"
    val price = 5
    val total = qty * price
    val record = name + " x" + qty + " = " + total

    println("record=" + record)
    println("total=" + total)
  }
}
  1. qty ← 3, name ← widget, price ← 5, total ← 15, record ← widget x3 = 15

    1object Main {2  def main(args: Array[String]): Unit = {3    val qty→ 3 = 3 //@qty=1, 104    val name→ widget = "widget"5    val price→ 5 = 56    val total→ 15 = qty3 * price57    val record→ widget x3 = 15 = namewidget + " x" + qty3 + " = " + total1589    println("record=" + recordwidget x3 = 15)10    println("total=" + total15)11  }12}
    outputrecord=widget x3 = 15
    total=15
  1. qty ← 1, name ← widget, price ← 5, total ← 5, record ← widget x1 = 5

    1object Main {2  def main(args: Array[String]): Unit = {3    val qty→ 1 = 14    val name→ widget = "widget"5    val price→ 5 = 56    val total→ 5 = qty1 * price57    val record→ widget x1 = 5 = namewidget + " x" + qty1 + " = " + total589    println("record=" + recordwidget x1 = 5)10    println("total=" + total5)11  }12}
    outputrecord=widget x1 = 5
    total=5
  1. qty ← 10, name ← widget, price ← 5, total ← 50, record ← widget x10 = 50

    1object Main {2  def main(args: Array[String]): Unit = {3    val qty→ 10 = 104    val name→ widget = "widget"5    val price→ 5 = 56    val total→ 50 = qty10 * price57    val record→ widget x10 = 50 = namewidget + " x" + qty10 + " = " + total5089    println("record=" + recordwidget x10 = 50)10    println("total=" + total50)11  }12}
    outputrecord=widget x10 = 50
    total=50