Can we revisit in which scenarios an explicit boolean conversion is
necessary?

On Wed, Dec 23, 2020 at 1:21 AM Moxley Stratton <moxley.strat...@gmail.com>
wrote:

> I would like revisit this issue.
>
> The issue was last discussed 5 years ago. Much has changed in that time.
> The given solution was to use a double-negative (!!) to convert a given
> value to a pure boolean.
>
> Here are the problems with the suggested solution:
> 1. I believe this solution is a hack that is not intuitive to beginners.
> It's rarely seen by mid and senior developers, meaning they have to pause
> to interpret what !! means.
> 2. A double negative can't be part of an Elixir pipeline.
> 3. The Credo package warns about double negatives: "Double boolean
> negation found". Linters in other languages have a similar warning. Other
> languages have a built-in function (JavaScript has Boolean()) to convert to
> boolean.
> 4. The alternative to double-negative is verbose: "if expr, do: true,
> else: false", or the less readable "expr && true || false"
>
> I would be happy to submit a PR to add Kernel.to_boolean/1.
>
> On Sunday, November 1, 2015 at 5:48:28 AM UTC-8 José Valim wrote:
>
>> Not necessarily , but the ones in Kernel are. :)
>>
>> --
>>
>>
>> *José Valim*
>> www.plataformatec.com.br
>> Skype: jv.ptec
>> Founder and Director of R&D
>>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/45dc9a7b-1657-4d02-933b-fe8fe182c2bcn%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/45dc9a7b-1657-4d02-933b-fe8fe182c2bcn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2B7iTRj%3Do62adGM%3DspKxnscAT1QoVC-0uqLDS_YPcDGAA%40mail.gmail.com.

Reply via email to