L
L
Leonid K2017-02-07 20:54:11
ruby
Leonid K, 2017-02-07 20:54:11

How is this done in ruby?

Which one can rewrite (python) 'hello world'[10:0:-2] to ruby?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oh_shi, 2017-02-07
@mreluzeon

It will not work in ruby ​​as laconic as with Python's slice notation.

'hello world'.reverse.scan(/(.).{1}/).join
=> "drwol"
'hello world'.reverse.scan(/(.).{2}/).join
=> "doo"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question