11/19 Using Code Blocks: I don't understand the comments


#1

https://www.codecademy.com/courses/ruby-beginner-en-ET4bU/2/3?curriculum_id=5059f8619189a5000201fbcb

I successfully passed this section but am having a hard time understanding what this comment means:

(It chooses to ignore the passed item, which is allowed.)

in the below code:

# The block, {|i| puts i}, is passed the current
# array item each time it is evaluated. This block
# prints the item. 
[1, 2, 3, 4, 5].each { |i| puts i }

# This block prints the number 5 for each item.
# (It chooses to ignore the passed item, which is allowed.)
[1, 2, 3, 4, 5].each { |i| puts i*5 }

Thanks all. :slight_smile:


#2

This post was flagged by the community and is temporarily hidden.


#3

I think that comment is only referring to the original code

[1, 2, 3, 4, 5].each { |i| puts 5 }

That comment is just saying that the method is not using the passed item.

Or said differently. .each time the item in the array is sent it is assigned the value of i however in the second case, nothing is done with that value. As to why you might want to do this, I have no earthly idea.