https://github.com/ankhers/argument_names
An easy to use and pipe friendly way to have named arugments
https://github.com/ankhers/argument_names
Last synced: about 1 year ago
JSON representation
An easy to use and pipe friendly way to have named arugments
- Host: GitHub
- URL: https://github.com/ankhers/argument_names
- Owner: ankhers
- License: mit
- Created: 2020-05-28T21:32:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-04T19:05:09.000Z (about 6 years ago)
- Last Synced: 2025-03-26T21:19:37.260Z (about 1 year ago)
- Language: Elixir
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Argument Names
An easy to use and pipe friendly way to have named arguments
## Examples
Suppose we have the following module
```elixir
defmodule Foo do
require ArgumentNames
import ArgumentNames
defnamed div(first, second) do
first / second
end
end
```
We can then start using the `first` and `second` names within our function calls.
```elixir
require Foo
Foo.div(second ~> 4, 2) => 0.5
```
We can also use this with pipes in order to change around our argument order
```elixir
4 |> Foo.div(first ~> 2) => 0.5
2 |> Foo.div(second ~> 4) => 0.5
```
We can also use this function with pipes without having to name the arguments
```elixir
2 |> Foo.div(4) => 0.5
```
## Roadmap
These are just a couple things I would like to see added to this package in no particular order
* Default arguments
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `argument_names` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:argument_names, "~> 0.2.0"}
]
end
```