Skip to content

69 Field declaration references ​

Task.title.field names the field declaration, independent of one object. read and write receive a concrete Task instance and preserve the field's String type.

norm
class Task { public String title }

main() {
  Task task = Task(title: "Draft")
  Field<Task, String> field = Task.title.field
  printLine(field.name())
  printLine(field.read(receiver: task))
  field.write(receiver: task, value: "Done")
  printLine(task.title)
}

Expected output:

text
title
Draft
Done

Try it: Create a second task and read its title through the same descriptor.

Precise rules: Reference.

Norm 0.25