我正在阅读这样的代码:
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
我不明白这个含义:end || current_commit
。有人能帮助我吗?
答案 0 :(得分:4)
块
match_index.downto(current_commit).find do |i|
log_container.term(i) == current_term
end
返回一个值,该值在逻辑上与current_commit
相加,结果在最顶层map
得出:
match_indices.values.map do |...|
BLOCK_RESULT || current_commit
end