Qur'an 2:251 is as follows:
So they defeated them by permission of Allah , and David killed Goliath, and Allah gave him the kingship and prophethood and taught him from that which He willed. And if it were not for Allah checking [some] people by means of others, the earth would have been corrupted, but Allah is full of bounty to the worlds.
What exactly did Allah taught to David in this verse?