8 How to set a value for select list, While using $entity->set('field_name_type_select_list', ["Se_the_optional_value"]); Programmatically? The following line of code I am trying to use,

use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_ENTITY_TYPE_update().
 */
function mymodule_node_update(EntityInterface $entity) {
  switch ($entity-&gt;getType()) {
    case "article":
      $entity-&gt;set('field_set_color', ["red","green"]);
      break;
  }
}


Why not able to set the value for a select list like this?
You can use hook_ENTITY_TYPE_presave as in hook_ENTITY_TYPE_update

When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.

use Drupal\node\NodeInterface;

function mymodule_node_presave(NodeInterface $node) {

  switch ($node-&gt;getType()) {
    case "article":

      $node-&gt;set('field_set_color', ["red","green"]);

      break;

  }

}