Does Elixir have a variable that contains the name of the current file (ala Rubys __FILE__)?

How can I specify the current compiled file in Elixir? In Ruby, I can use a variable __FILE__. Is there an equivalent in Elixir?

Here is my script:

IO.puts "#{__FILE__}"

Here is the result:

** (CompileError) ModulesAndFunctions-7.exs:3: undefined function __FILE__/0
    (elixir) expanding macro: Kernel.to_string/1
    ModulesAndFunctions-7.exs:3: (file)
+4
source share
1 answer

You can just use __ ENV __. file

+7
source

All Articles