From: zverok.offline@... Date: 2019-07-23T20:46:08+00:00 Subject: [ruby-core:93895] [Ruby master Feature#16017] String and Array Slices Issue #16017 has been updated by zverok (Victor Shepelev). I recommend [String](https://ruby-doc.org/core-2.6.3/String.html) and [Array](https://ruby-doc.org/core-2.6.3/Array.html) docs, they are pretty straightforward and list everything you might do with them. We do have ranges to slice: ```ruby "hello, world!"[3...9] # => "lo, wo" "hello, world!"[3..9] # two dots mean including end # => "lo, wor" [1,2,3,4,5][1...3] # => [2, 3] [1,2,3,4,5][-3..] # => [3, 4, 5] [1,2,3,4,5][-3...-1] ``` Though, Ruby's slicing kinda less powerful than Python's: currently, we don't have a way to express the third argument (step), though potential syntax (in the form of `(3...9) % 2`) was introduced in the latest version. I believe this last feature was not really popular requirement to add, as lacking really compelling real-life use cases. ---------------------------------------- Feature #16017: String and Array Slices https://bugs.ruby-lang.org/issues/16017#change-79925 * Author: D1mon (Dim F) * Status: Open * 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: