converted chapter 25 examples to Swift