converted first chapter 15 example to swift