H.M.S. Pinafore
Little Buttercup now reveals her secret.  Many years ago, she had cared for two babies. One baby was of low birth, but the other was a wellborn babe.  She "mixed those children up"  the wellborn babe is Ralph and the Captain is the babe of low condition. Sir Joseph realises that Ralph should have been the Captain, and the Captain should have been Ralph.  He calls for both, and they enter wearing one another's uniforms. Sir Joseph's marriage with Josephine is now out of the question. He hands her to Ralph. Corcoran will marry Buttercup. Sir Joseph will marry Hebe. There is general rejoicing.