System.get_env/2 in `mix` generated boiler plate code

In Phoenix mix generated boiler plate code System.get_env/2 being used in wrong way, correct me if I misunderstood it
in multiple places it used, below snippet is in config/runtime.exs:36

  secret_key_base =
    System.get_env("SECRET_KEY_BASE") ||
      raise """
      environment variable SECRET_KEY_BASE is missing.
      You can generate one by calling: mix phx.gen.secret

  host = System.get_env("PHX_HOST") || ""
  port = String.to_integer(System.get_env("PORT") || "4000")

after Elixir 1.9.0 Sytem.get_env(“PORT”) it always returns nil if there no “PORT” declared in environment variables because System.get_env/2 has default value of nil, so it never reaches to || "4000" value

iex(1)> nil || "4000" 

If left operand of ||/2 is falsy (false or nil) it will return the right hand side of the expression.

1 Like

thank you for correcting me