Skip to content

Instantly share code, notes, and snippets.

@catsby
Last active October 23, 2016 03:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save catsby/6623829 to your computer and use it in GitHub Desktop.
Save catsby/6623829 to your computer and use it in GitHub Desktop.
Requiring relatively with Elixir
$ ls
other_thing.exs
thing.exs
$ elixir thing.exs
calling other
other thing!
hooray!
defmodule OtherThing do
def other do
IO.puts "other thing!"
end
end
defmodule Thing do
Code.require_file "other_thing.exs", __DIR__
def do_something do
IO.puts "calling other"
OtherThing.other()
IO.puts "hooray!"
end
end
Thing.do_something()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment