[ruby-core:93554] [Ruby master Feature#15987] Let boolean option (such as `exception` in `Kernel#Complex`, `Kernel#Float`, `Kernel#Integer`, `Kernel#Rational`) be falsy vs. truthy

From: shevegen@...
Date: 2019-07-05 06:02:14 UTC
List: ruby-core #93554
Issue #15987 has been updated by shevegen (Robert A. Heiler).


I don't have a huge preference either way, but this may be a design decision, so perhaps we
can ask matz either way; also in how strong the concept of "falsy" and "truthy" is in ruby.
I assume there were design considerations for when matz added nil and false and not 
considered both to be equivalent (e. g. if some value is nil, you can use that to 
distinguish it from true or false).

I think we can find examples where nil being treated as false makes sense, but we may also
consider cases where nil being false does not make a whole lot of sense, e. g. if that
variable would lateron be initialized to become a String or Array. Perhaps that may
have been a reason why you did limit the suggestion to only specific methods, e. g.
chomp in Kernel#gets. For specific methods, it may be that it makes sense to only
distinguish true/false boolean states.

Aside from the conceptual and design consideration, what impact would we be able to 
observe if this would be changed? I have not thought through all the given methods
yet. :)

----------------------------------------
Feature #15987: Let boolean option (such as `exception` in `Kernel#Complex`, `Kernel#Float`, `Kernel#Integer`, `Kernel#Rational`) be falsy vs. truthy
https://bugs.ruby-lang.org/issues/15987#change-79124

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Some boolean options (such as the `exception` option in `Kernel#Complex`, `Kernel#Float`, `Kernel#Integer`, and `Kernel#Rational`) distinguish `false` vs. other values. But in most other cases where a boolean notion is concerned (for example, the `chomp` option in `Kernel#gets`), the distinction is between falsy vs. truthy values.

I request the distinction to be falsy vs. truthy. In other words, I would like the value `nil` to work on the falsy side rather than the truthy side. I listed some such options here, but perhaps there are other options that I missed. I would like the request to be applied for those options too.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next