The return value of the block passed to each (false
) is thrown away. The explicit return works because that returns from the method, not the block. You instead want:
def board_check?
@board.each do |row|
return true if row.include("foo")
end
return false
end
But really you want to use any?
:
def board_check?
@board.any? do |row|
row.include("foo") # or perhaps check_row_for_truth_conditions(row)
end
end
Also, your check_row_for_truth_conditions can be simplified to just this:
def check_row_for_truth_conditions(row)
row.include("foo")
end
No need for the explicit return true
/false
.