From: "mame (Yusuke Endoh)" Date: 2012-11-20T20:53:19+09:00 Subject: [ruby-core:49678] [ruby-trunk - Feature #3653] Diferential behaviour of positives and negatives ranges as subindex of string or arrays. Issue #3653 has been updated by mame (Yusuke Endoh). Description updated Target version set to next minor ---------------------------------------- Feature #3653: Diferential behaviour of positives and negatives ranges as subindex of string or arrays. https://bugs.ruby-lang.org/issues/3653#change-33195 Author: dsilber (Daniel Silberschmidt) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: next minor =begin The expression '[a..b]' when applied to a string or to an array return the slice from the string/array from a to b. for example [0..3] returns the first four letters from a string irb(main):004:0> "carromato"[0..3] => "carr" the slice [-4..-1] returns the last four letters from a string irb(main):005:0> "carromato"[-4..-1] => "mato" but if the length of the original string is smaller than the slice the results are conceptually very different depending on positive or negative indexes: irb(main):006:0> "carromato"[0..24] => "carromato" irb(main):007:0> "carromato"[-25..-1] => nil I would like a simetric behaviour in the last case returning the whole word (and not nil). It would be more natural to have the same behaviour when exeding by left of by right of the string/array. Does Anbody agree or disagree whith my position? Daniel =end -- http://bugs.ruby-lang.org/