[#80531] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...>
SASADA Koichi <ko1@ruby-lang.org> wrote:
On 2017/04/02 11:35, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
Eric Wong <normalperson@yhbt.net> wrote:
On 2017/05/08 9:33, Eric Wong wrote:
On 2017/05/08 10:53, SASADA Koichi wrote:
SASADA Koichi <ko1@atdot.net> wrote:
On 2017/05/08 12:01, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
On 2017/05/08 15:36, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
On 2017/05/09 12:38, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
On 2017/05/09 14:12, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
On 2017/05/09 15:23, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
Thank you.
[#80763] [Ruby trunk Feature#13434] better method definition in C API — naruse@...
Issue #13434 has been updated by naruse (Yui NARUSE).
[#80844] [Ruby trunk Bug#13503] Improve performance of some Time & Rational methods — watson1978@...
Issue #13503 has been updated by watson1978 (Shizuo Fujita).
[#80892] [Ruby trunk Misc#13514] [PATCH] thread_pthread.c (native_sleep): preserve old unblock function — ko1@...
Issue #13514 has been updated by ko1 (Koichi Sasada).
ko1@atdot.net wrote:
On 2017/04/27 8:58, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
Eric Wong <normalperson@yhbt.net> wrote:
[ruby-core:80615] [Ruby trunk Feature#13395] Add a method to check for not nil
Issue #13395 has been updated by shevegen (Robert A. Heiler).
I think that these discussions come up with some frequency; if I recall correctly,
Tsuyoshi Sawada was proposing something that I agreed with in principle. But I
did point out that the english language appears to have it easier with positive
assertions rather than negative ones.
I am not against .not_nil? per se, mind you, since it may be symmetrical for .nil?
cases and the example give by darix (if nil, if !nil?, unless nil?) but I think
it is something that is somewhat showing a limitation of the english language as
such.
I actually found that the simplest way, for my own code, is to try to formulate
things "positively" whenever possible.
So:
if condition
end
if condition1 and condition2
end
A similar explanation I use for .select or .reject, I
almost always go to pick exactly what I need to have.
Like a filter where you apply the filtering in a
forward fashion (you could of course always revert the
filter, like to use .reject rather than .select, or
within the block clause, invert the checks).
To the suggestion itself in regards to .count, perhaps
this may be worthwhile to have some special meaning for
what a user may want to count for.
In non-legal ruby, consider this:
array = [1, 'dog', nil]
array.count(! &:nil?)
Granted, not very readable. :)
Then again, I also consider the & not really readable either.
How about:
array = [1, 'dog', nil]
array.count(:not_nil)
or
array.count(:not_nil)
Hmm...
To be honest, I don't think that these examples are really that
great.
In the above example, using .compact may be simpler:
array.compact.size
For the latter, perhaps a method that does it, like .not_nil? but
I am not sure if this is used that much to warrant an addition.
I do somewhat agree with ogarci5 by the way - not necessarily because
of the explanation, but because in case 3 he gave, you do not have
to use "unless" and neither the invert "operator" "!", which is
usually much easier and more straightforward. So in that context,
I actually agree, having that flexibility may be a good thing,
even if I don't like the name .not_nil? a lot.
I still think that it is a limitation of the english language.
Consider a backpack in a RPG/rogue-like game. You want to
query whether it is empty or filled:
if backpack.empty? # Seems simple.
if !backpack.empty? # Seems ok although more difficult to understand
if backpack.filled? # Hmmm... filled with what?
if backpack.not_empty? # Not ideal but perhaps also better than the other two examples before
So I kinda semi-agree with ogarci5; I still think that the english language
itself is the one that has the biggest problems here with negations, followed
by the human brain modeling concepts. (OOP is a modeled concept too after all)
----------------------------------------
Feature #13395: Add a method to check for not nil
https://bugs.ruby-lang.org/issues/13395#change-64121
* Author: JustJosh (Joshua Stowers)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
There does not seem to be a method in Ruby to check if an object is *not* nil.
Such a method could help with readability.
Example:
> ~~~ ruby
> array = [1, 'dog', nil]
> array.count(&:not_nil?)
> ~~~
> vs
> ~~~ ruby
> array = [1, 'dog', nil]
> array.reject(&:nil?).count
> ~~~
--
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>