[Solved] Enumerate() in Ruby | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

[Solved] Enumerate() in Ruby

In Python I can easily use enumerate() to do stuff like this: https://code.sololearn.com/c3jb0lHqRGwW/?ref=app Is it possible to do the same in Ruby?

22nd Dec 2019, 6:04 AM
Diego
Diego - avatar
2 Answers
+ 5
With help of stackoverflow I came to this solution: a = [8, 17, 29, 42] a.each_with_index do |s,i| puts "#{i} #{s}" end source: https://stackoverflow.com/questions/13936922/pythons-enumerate-in-ruby
22nd Dec 2019, 9:17 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
Diego Thank you :)
23rd Dec 2019, 8:05 AM
Denise Roßberg
Denise Roßberg - avatar