Reputation: 8113
I am reading a code piece like this:
def majority_agreed_commit
current_commit = log_container.last_commit
current_term_match_indices = match_indices.values.map do |match_index|
match_index.downto(current_commit).find do |i|
log_container.term(i) == current_term
end || current_commit
end
I don't understand the meaning of this: end || current_commit
. Could anybody help me?
Upvotes: 0
Views: 29
Reputation: 121000
Block
match_index.downto(current_commit).find do |i|
log_container.term(i) == current_term
end
returns a value, this value is logically added against current_commit
and the result is being yielded in topmost map
:
match_indices.values.map do |...|
BLOCK_RESULT || current_commit
end
Upvotes: 4