This will work:
defguard to_boolean(term) when term not in [false, nil]
On Wed, 23 Dec 2020 15:02:43 -0500
Austin Ziegler wrote:
> It would be easy enough to provide this as a predicate in your own
> code if that’s your style preference
>
> ```elixir
> def boolean(falsy) when falsy in
> e.g if you have a function with the same name but one less argument
That can actually also be considered as a function with default values (and
in the end, default values generate such functions with different arities).
If not then I think it's a code smell and the function needs to be
Sorry, meant to say “in being able to say only import this *function*”, not
story :)
On Fri, Dec 25, 2020 at 5:42 PM Zach Daniel
wrote:
> There are theoretical name conflicts from not being able to say “only
> import this story” (e.g if you have a function with the same name but one
> less
There are theoretical name conflicts from not being able to say “only
import this story” (e.g if you have a function with the same name but one
less argument) what about import Mod, only: [func: 1..3]?
On Fri, Dec 25, 2020 at 5:36 PM thojan...@gmail.com
wrote:
> Say function `foo` has multiple
Say function `foo` has multiple default values (two required args, two with
defaults). When importing, we must specify each arity that is used in the
calling code, e.g.
```
import Foo, only: [foo: 2, foo: 3, foo: 4]
foo(1, 2)
foo(1, 2, 3)
foo(1, 2, 3, 4)
```
I expected that I could only