operator [] method

Message operator [](
  1. String attributeName
)
override

When we create these from strings or from AST nodes, we want to look up and set their attributes by string names, so we override the indexing operators so that they behave like maps with respect to those attribute names.

Implementation

Message operator [](String attributeName) {
  switch (attributeName) {
    case "female":
      return female;
    case "male":
      return male;
    case "other":
      return other;
    default:
      return other;
  }
}