"Ask, and it will be given to you; seek, and you will find; knock, and it will be opened to you. "For everyone who asks receives, and he who seeks finds, and to him who knocks it will be opened. "Or what man is there among you who, when his son asks for a loaf, will give him a stone? "Or if he asks for a fish, he will not give him a snake, will he? "If you then, being evil, know how to give good gifts to your children, how much more will your Father who is in heaven give what is good to those who ask Him! (Matthew 7:7-11 NASB)
Again I marvel at the logical flow of Christ's teaching in the Sermon on the Mount. The first 6 verses of the 7th chapter addressed judging others, and then you get hit with the passage above. Realize that what follows this passage is 'The Golden Rule' in Matthew 7:12, which seems to continue on the theme of not judging and how to act with regard to other people. But sandwiched between 6 verses about judgment, and the golden rule sits this passage about seeking first the kingdom of God and His righteousness.
Discernment is a very difficult thing for even the most discerning of believers. We know that the nature of a man is to sin, so to trust one's own judgment is not wise. Jesus commands in Matthew 7:1-5 not to judge, and warns that we will be judged by our own standard. Moreover in 7:3-5 He makes it clear that we are in no place to judge the specks in another's eyes considering the logs in our own eyes. Now He tempers all of this in 7:6 but saying not to forgo all discernment and just cast pearls to swine and give what is holy to dogs. This idea that we cannot judge and at the same time we must discern leaves our heads spinning. Jesus knows the difficulty here so he comes in with verses 7-11. "Ask, and it will be given to you; seek, and you will find; knock, and it will be opened to you..." Here is an important question: "Ask for what?" In light of the context it appears to be wisdom and discernment, the answer to the question on how to discern or judge is to ask, seek, and knock not relying on your own strength, wisdom, or insight. This passage is not about food and sustenance it is about wisdom and discernment. If we seek God for wisdom, will He give us foolishness? Of course not! Would you give your child a stone if they needed bread? How much more will your father give what is good to those who ask Him!
Again it is so important to see where the passage falls when it comes to understanding its meaning.