converted first chapter 17 example to Swift