In a moment of anger, I was speaking to a friend of mine and he asked me what if I was given a third daughter? I said to him: If my wife gives birth to a third daughter, I will divorce her. But I did not mean what I said. Does this count as a divorce (talaaq)?
Your saying “If my wife gives birth to a third daughter, I will divorce her” comes under the heading of promising to divorce in the future. If she gave birth to a daughter but you did not divorce her, then nothing has happened. This is confirmed by the fact that you did not mean what you said: you did not intend for a divorce to happen at that time and you did not make it conditional upon her giving birth to a daughter.
But if you said, “If my wife gives birth to a third daughter then she is divorced,” then divorce takes place if she gives birth to a third girl.
You should beware of using the words of divorce (talaaq) in ways other than that for which they were prescribed, namely ending a marital relationship when the husband decides to do that for reasons which make it permissible to divorce.
And Allah knows best.