Quantcast
Channel: Ruby Issue Tracking System: shevegen (Robert A. Heiler)
Viewing all articles
Browse latest Browse all 100

Ruby master - Feature #16822: Array slicing: nils and edge cases

$
0
0

I do not have a strong preference here either way; I guess one can reason in
favour for both behaviour types/styles, and I think a primary point in the
suggestion is that it refers to startless/endless situations, such as "5..",
which I don't use myself, but one slight concern is this one:

a[-1..-2] # => [] 
a[-10..-9] # => nil 

Is this certain to not break a lot of code? I have not checked myself and I
rarely use #slice anyway, but I do use a lot of [] in general. It's one of
my favourite method calls in general, in ruby. :)

Admittedly I actually don't remember off-hand having ever used two negative
indices here ... for some reason, I seem to use 0 or positive numbers a lot
more.

No idea how/if other ruby users use or rely on that behaviour though but I
think it would be important to get some specific overview about any potential
effect (or side-effect) of proposed changes, even if the reasoning given is
ok.


Viewing all articles
Browse latest Browse all 100

Trending Articles