Re: Using enums to avoid default true in "settings dictionaries" (#466, #467, #471)

On Fri, Feb 19, 2016 at 10:50 PM, Martin Thomson <martin.thomson@gmail.com>
wrote:

> On 19 February 2016 at 21:50, Peter Thatcher <pthatcher@google.com> wrote:
> > But how does converting to an enum help at all?   Wouldn't undefined then
> > just get turned into an enum value, which is truthy?
>
> An enum ensures that all valid values that are equally truthy, so
> truthy/falsy becomes irrelevant.  Yes, the default is truthy, but so
> is every valid value.
>
​
So pc.createDataChannel("label", {ordered: undefined}) is still going to be
ordered, right?

So how are we better off with an enum in this case?


> > And if a truthy value of a default is discouraged, then are the only
> > encouraged defaults the falsy ones (false/null/""/0/NaN)?
>
> This is only relevant for dictionary parameters with Boolean types.
>

Received on Saturday, 20 February 2016 07:37:46 UTC