Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4634

Iterating over a Nested array in ruby

$
0
0
test_scores = [  [97, 76, 79, 93], [79, 84, 76, 79], [88, 67, 64, 76], [94, 55, 67, 81]]puts test_scores.any? do |scores|  scores.all? { |score| score > 80 }end

When I run the above code on Replit & my local machine(WSL) the output is found 'true'. However, as per the explanation of the Odin Project and ChatGPT the output should be 'false'. The Odin project says, "This seems pretty straight-forward. It returns false, because none of the nested arrays have scores that are all over 80". Odin project link


Viewing all articles
Browse latest Browse all 4634

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>