Docker compose and environment variables

I have read this
Ways to set environment variables with Compose | Docker Docs

But is not clear to me if this is a good practice in docker compose although it works:

environment:
 - variable

and then in the env file

variable=true

Hi

Check out the answer in: What is the use of enviroument variable if the .env already existed