Skip to content

Instantly share code, notes, and snippets.

@remi
Created July 14, 2021 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remi/9323dd147ce554440b6c538c84ae4443 to your computer and use it in GitHub Desktop.
Save remi/9323dd147ce554440b6c538c84ae4443 to your computer and use it in GitHub Desktop.
defmodule Example1 do
@default_now DateTime.utc_now()
def foo(now \\ @default_now) do
IO.puts(now)
end
end
defmodule Example2 do
def foo(now \\ DateTime.utc_now()) do
IO.puts(now)
end
end
Example1.foo()
Example2.foo()
Process.sleep(10000)
Example1.foo()
Example2.foo()
Process.sleep(10000)
Example1.foo()
Example2.foo()
$ elixir test.exs
2021-07-14 15:01:48.062782Z
2021-07-14 15:01:48.088374Z
2021-07-14 15:01:48.062782Z
2021-07-14 15:01:58.088991Z
2021-07-14 15:01:48.062782Z
2021-07-14 15:02:08.089879Z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment