Reputation: 6352
Documentation gives example of usage in iex
- and it works there:
http://elixir-lang.org/getting-started/processes.html#send-and-receive
Though it doesn't work inside of script:
$ elixir e.exs
** (CompileError) e.exs:6: undefined function flush/0
(elixir) lib/code.ex:363: Code.require_file/2
I found that this function is part of some IEx.Helpers
https://hexdocs.pm/iex/master/IEx.Helpers.html
But prepending use IEx.Helpers
or use IEx
at the beginning of script doesn't give effect.
Upvotes: 1
Views: 1536
Reputation: 10061
You do not want to use the use
keyword. You are going to either want alias
or import
.
They are all related, but slightly different.
import Foo.Bar
- will import all of the functions defined in the Foo.Bar
module allowing you to call function()
alias Foo.Bar
- will also import all of the functions defined in the module Foo.Bar
. The difference is that now you need to use Bar.function()
instead of just function()
.use Foo.Bar
- will call a macro inside of the Foo.Bar
module called __using__/1
.You can read more about the difference of these words and more here.
Upvotes: 2