Jenkins: How to use choice parameter in declarative pipeline?

The documentation for declarative jenkins pipelines says:

A choice parameter, for example:

pipeline { 
    .....
     parameters { 
       choice(name: 'CHOICES', choices: ['one', 'two', 'three'], description: '') }

First one is the default value


You need to use \n instead of \. See this code:

  pipeline {
  agent any
  parameters {
    choice(
        name: 'myParameter',
        choices: "Option1\nOption2",
        description: 'interesting stuff' )
  }
}

The arguably most elegant way to separate choices is by using an array like so:

pipeline {
  agent any
  parameters {
    choice(
      name: 'Env',
      choices: ['DEV', 'QA', 'UAT', 'PROD'],
      description: 'Passing the Environment'
    )
  }
  stages {
    stage('Environment') {
      steps {
        echo " The environment is ${params.Env}"
      }
    }
  }
}