我有一個呼叫布爾函式的代碼。
can_process = done_recently?(load)
這是 done_recently 函式的外觀。
def done_recently?(load)
time_window = 10000
load['terminatedAt'] && (load['terminatedAt'] > time_window.minutes.ago.utc.iso8601)
end
在我的 json 資料中,里面
“負載”:[{“終止在”:空}]
在許多其他資料中。在呼叫這些函式之前,此 json 資料將轉換為哈希。
done_recently 會做什么?函式回傳(真/假)?我是紅寶石的新手,所以我有點困惑。請幫幫我。
我曾嘗試在 irb 中進行復制,但由于一些錯誤而中途感到困惑。
uj5u.com熱心網友回復:
{ "terminatedAt": null }當您的輸入是
def done_recently?(load)
time_window = 10000
load['terminatedAt'] && (load['terminatedAt'] > time_window.minutes.ago.utc.iso8601)
end
將回傳nil。被回傳是因為評估nil的第一部分被認為是虛假的,并且在第二部分之后的第二部分將不再被評估并立即回傳。load['terminatedAt'] && ...nil&&nil
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/529715.html
上一篇:使用多個決勝局對串列進行排序
