When metals bond with nonmetals, electrons are transferred from the metal to the nonmetal, resulting in the formation of an ionic compound?