Do not answer a fool according to his foolishness, etc. Answer a fool according to his foolishness, lest he be wise in his own eyes. These should not be seen as mutually contradictory, not to answer a fool according to his foolishness, and to answer a fool according to his foolishness: for both correspond according to the diversity of times and persons, while the fool is also disregarded because he does not receive wisdom, and foolish pride is checked by another kind of foolishness, just as the Apostle also says, I have become a fool, you compelled me (II Cor. XII).
Source: Commentary on Proverbs