(6:9) These are the offspring of Noah—Noah was a righteous man, faultless in his generation. Noah walked with God.
A righteous man, faultless in his generation This was said in Noah's absence. But further on, when God is speaking to Noah directly, He says, “I have seen that you are righteous before Me in this generation” (7:1), praising him only for his righteousness, whereas in Noah's absence he is praised fully, for being both righteous and faultless. Why the diminished praise in his presence?
R. Yirmeyah b. Elazar said: Only part of a person's praise should be said in his presence, but all of his praise should be said in his absence (Eruvin 18b).
NOTE: Rashi explains: Praising him fully to his face may be interpreted as flattery.
in his generation R. Yochanan said: In his generation of very wicked people, he was considered perfectly righteous, but he would not have been considered perfectly righteous in other generations that were not as wicked. But Resh Lakish said: If in his wicked generation he was able to be righteous, he surely