Head First Kotlin Dawn Griffiths David Griffiths Head First Kotlin by Dawn Griffiths and David Griffiths Copyright © 2019 Dawn Griffiths and David Griffiths. All rights reserved. Printed in Canada. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Series Creators: Kathy Sierra, Bert Bates Editor: Jeff Bleiel Cover Designer: Randy Comer Production Editor: Kristen Brown Production Services: Jasmine Kwityn Indexer: Lucie Haskins Brain image on spine: Eric Freeman Page Viewers: Mum and Dad, Laura and Aisha Printing History: February 2019: First Edition. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. The Head First series designations, Head First Kotlin, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and the authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. No Duck objects were harmed in the making of this book. ISBN: 978-1-491-99669-0 [MBP] To the brains behind Kotlin for creating such a great programming language. Authors of Head First Kotlin Dawn Griffiths has over 20 years experience working in the IT industry, working as a senior developer and senior software architect. She has written various books in the Head First series, including Head First Android Development. She also developed the animated video course The Agile Sketchpad with her husband, David, as a way of teaching key concepts and techniques in a way that keeps your brain active and engaged. When Dawn’s not writing books or creating videos, you’ll find her honing her Tai Chi skills, reading, running, making bobbin lace, or cooking. She particularly enjoys spending time with her wonderful husband, David. David Griffiths has worked as an Agile coach, a developer and a garage attendant, but not in that order. He began programming at age 12 when he saw a documentary on the work of Seymour Papert, and when he was 15, he wrote an implementation of Papert’s computer language LOGO. Before writing Head First Kotlin, David wrote various other Head First books, including Head First Android Development, and created The Agile Sketchpad video course with Dawn. When David’s not writing, coding, or coaching, he spends much of his spare time traveling with his lovely wife—and coauthor—Dawn. You can follow Dawn and David on Twitter at https://twitter.com/HeadFirstKotlin. how to use this book: Intro NOTE In this section, we answer the burning question: “So why DID they put that in a book on Kotlin?” Who is this book for? If you can answer “yes” to all of these: 1. Have you done some programming? 2. Do you want to learn Kotlin? 3. Do you prefer actually doing things and applying the stuff you learn over listening to someone in a lecture rattle on for hours on end? this book is for you. NOTE This is NOT a reference book. Head First Kotlin is a book designed for learning, not an encyclopedia of Kotlin facts. Who should probably back away from this book? If you can answer “yes” to any of these: 1. Is your programming background limited to HTML only, with no scripting language experience? (If you’ve done anything with looping, or if/then logic, you’ll do fine with this book, but HTML tagging alone might not be enough.) 2. Are you a kick-butt Kotlin programmer looking for a reference book? 3. Would you rather have your toenails pulled out by 15 screaming monkeys than learn something new? Do you believe a Kotlin book should cover everything, especially all the obscure stuff you’ll never use, and if it bores the reader to tears in the process, then so much the better? this book is not for you.