Bug #16178

Updated by Eregon (Benoit Daloze) about 3 years ago

Currently on trunk: 
 array = ["string", 42, [1, 2]] { |x| x * 2 } 
 # => ["stringstring", 84, [1, 2, 1, 2]] { _1 * 2 } 
 # => ["stringstring", 84, 2] 

 Oops, this trivial code just lost data and completely ignored the element class! 
 This is clearly contrary to intuition and is very dangerous. 

 Using `_0` instead has the correct behavior but it's clear we use 1-based indexing for numbered parameters, 
 and it doesn't solve that `_1` has dangerous behavior. 

 Basically the current behavior is that `_0` is the same as `|x|` and `_1` is the same as `|x,|`. 
 `|x,|` is almost never used in Ruby, and for good reasons, it just throws away data/information/the class of the object. 
 Such a dangerous operation should only be done when it's explicit, and the trailing comma in `|x,|` shows that, but `_1` does not. 

 So let's make `_1` be `|x|` and remove `_0`. 

 I am going to be harsh, but this discussion has gone too long without any serious written argument for the current behavior: 
 I believe it's irrational and irresponsible to have `_1` be `|x,|`, it's just going to lead to nasty bugs. 

 Try to convince me otherwise. 
 If not, in one week I want to apply this change. 

 From the discussion in 
 and in 

 Some reactions to this behavior in