Skip to content

78 Field handles ​

bind(task) combines a typed field descriptor with one class instance. The FieldHandle<String> can read and write that object's field later; it is distinct from lexical ref<T>.

norm
class Task { public String title }

main() {
  Task task = Task(title: "Draft")
  FieldHandle<String> handle = Task.title.field.bind(task)
  printLine(handle.read())
  handle.write("Done")
  printLine(task.title)
}

Expected output:

text
Draft
Done

Try it: Bind the same field on a second task and compare results.

Precise rules: Reference.

Norm 0.25