A section of brass pipe to connect to ferrous (galvanized/iron) pipe was recommended before the days of dielectric unions. I would agree with RP that the dielectric union is better, in that the union interposes a piece of plastic insulator between the two types of pipe (Cu and Fe), which precludes any electrical connection. Brass-copper connection will allow current to flow, and eventually some electrolytic corrosion will occur. Effectively this will be minimal with a good section of brass to connect the pipes. I’ve seen brass-iron connections that are still quite good even though they’re more than 50 years old. The old rule for brass connections was that you should use at least 5-6 inches of brass nipple for the connection.
It is also important to use red rather than yellow brass for these connections. Brass is a copper-zinc slloy. red brass is 84-86% copper, the rest zinc. Yellow brass is 65% copper, the rest zinc. The red stuff is better, suffers less from “dezincification” (corrosion), and lasts longer.