I think we have lots of occasions to receive a true or false value as a string input, and want to convert it to true or false. Perhaps we can have a method Kernel#Boolean in a similar spirit to Kernel#Integer and its kins, which takes an optional keyword argument exception (similar to https://bugs.ruby-lang.org/issues/12732) and strict (defaulted to true).
Please note that this proposal is distinct from any proposal to introduce the Boolean class into Ruby. In think the latter does not make sense, and I am against it.
The proposal is still vague, especially when strict: false. The criteria are totally culture dependent.
"yes" may be true for English speaking people, but what about "はい" (Japanese) or "Ja" (German)? The list would go on.
Until the ambiguity resolved, I am against the proposal.
I agree that the proposal was vague. Instead of using strict, perhaps we can pass a string or strings expressing the language/mode that we want to allow.
I think we have lots of occasions to receive a true or false value as a string input, and
want to convert it to true or false.
I agree. :)
Not saying that I agree with the API, it feels a bit cumbersome; but I agree with the
comment above.
By the way, I think the first two cases are the one that are the least ambiguous
since they only evaluate the two strings "true" and "false" into the respective
true and false representation:
(The name "Boolean" is a bit strange though... where does this reside then? In
Kernel? Why not to_bool or to_boolean? Though admittedly the latter also includes
the word "boolean", I guess the uppercased leading part confuses me a bit. I am
aware of Kernel#Integer() or whever it resides, but I think that in general it
may be better to not use too many upcased method names; in ruby we have a lot of
flexibility like .Foo() or class Foo; Foo[] - but anyway, this is a side comment,
as written above I agree with what Tsuyoshi Sawada stated :) )