From: shevegen@... Date: 2019-07-24T07:28:25+00:00 Subject: [ruby-core:93899] [Ruby master Feature#16017] String and Array Slices Issue #16017 has been updated by shevegen (Robert A. Heiler). I use both ruby and python; ruby significantly more than python though. First, to the direct comparison - I am against using : in ruby. It does not make a whole lot of sense (to me). For equivalent purposes we have: Python: "hello, world!"[3:9] # => 'lo, wo' Ruby: "hello, world!"[3,6] # => "lo, wo" I think it would confuse people if ruby were to add a notation using **:** . As for the step parameter, I have no strong feelings pro or con, although I personally never needed it. I am not sure if it is really needed either. Programming languages are different and while some features in other languages may appear useful, I am not sure that a 1:1 translation really often makes sense. In this case here, I think retaining the old way would be best, to avoid adding potential confusion, in particular when the : variants would behave like python does (and if they would not, then you could suddenly claim that this is confusing to python-users, so this would only add further different expectations). > I believe this last feature was not really popular requirement > to add, as lacking really compelling real-life use cases. Agreed. This may also be a question whether people would really need a step parameter to begin with. On a side note - I disagree that ruby "lacks" something or has a "less powerful" anything here. ;) Anyway, this is just my opinion - you only have to convince matz about pros/cons of a feature in the end. By the way, to reverse an array, this is more rubyish: [1,2,3,4,5].reverse => [5, 4, 3, 2, 1] I do not think [::-1] is elegant or makes sense from the context of ruby. Python has another approach to functions as such - they seem to have a much higher imminent focus in python. I have no real problem with python, but I like ruby's approach and philosophy more in this regard, since it seems to make more sense to me. ---------------------------------------- Feature #16017: String and Array Slices https://bugs.ruby-lang.org/issues/16017#change-79945 * Author: D1mon (Dim F) * Status: Feedback * Priority: Normal * Assignee: * Target version: ---------------------------------------- Recently began to study Ruby and lacks some things from the python. I wish they were added to Ruby. ``` python "hello, world!"[3:9:2] # 'l,w' "hello, world!"[3:9] # 'lo, wo' [1,2,3,4,5][1:3] # [2, 3] [1,2,3,4,5][1:5:2] # [2, 4] ``` -- https://bugs.ruby-lang.org/ Unsubscribe: