continuing with swift translation of chapter 6 examples