https://github.com/techgaun/named_arguments
Python like named arguments in Elixir
https://github.com/techgaun/named_arguments
elixir named-arguments
Last synced: 4 months ago
JSON representation
Python like named arguments in Elixir
- Host: GitHub
- URL: https://github.com/techgaun/named_arguments
- Owner: techgaun
- License: mit
- Created: 2018-03-12T03:56:56.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-01T23:53:55.000Z (over 7 years ago)
- Last Synced: 2025-07-08T14:55:52.805Z (10 months ago)
- Topics: elixir, named-arguments
- Language: Elixir
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# named_arguments [](https://hex.pm/packages/named_arguments)  [](https://travis-ci.org/techgaun/named_arguments)
> Named arguments in Elixir
This package abuses macros to use keyword lists
and maps to mimic named arguments in Elixir.
Installation:
```elixir
{:named_arguments, "~> 0.1.0"}
```
The usage is very simple:
```elixir
defmodule Analyzer do
use NamedArguments
def query(opts \\ [aggregate: :sum, range: "1h"]) do
IO.puts "running query with #{opts[:aggregate]} over range #{opts[:range]}"
end
end
Analyzer.query()
# running query with sum over range 1h
Analyzer.query(aggregate: :avg)
# running query with avg over range 1h
```
While the above example shows Keyword list example, this works fine with maps as well.
You can check the [test](test/named_arguments_test.exs) for more examples.