We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Ruby - Enumerable - each_with_index
Ruby - Enumerable - each_with_index
Sort by
recency
|
92 Discussions
|
Please Login in order to post a comment
Compiled Answer
https://github.com/LinaOrmos/Ruby/blob/main/Enumerable%20-%20each%20with%20index%20HackerRank
The challenge statement, here:
doesn't exactly explain what the
skip_animals
method is supposed to do—you have to return an array of the elements with the indices prefixed like the example shows.I've noticed a lot of the Ruby challenges hide parts of the source code from you, and I think it can be useful to see everything that's being run to help learn even more about the language. Luckily, with
File.read(__FILE__)
we can see the full source code.The full source code for this challenge is as follows.
Whats wrong with my code?