opkcq.blogg.se

Kotlin list to set
Kotlin list to set








kotlin list to set

Finally, both lists have the titles in a particular order.In Kotlin, the items in a list are called elements*. Next, both lists have items in them - in this case, the titles of the books.In Kotlin, the name of the variable holding the list is kind of like the name of the list on paper. The handwritten list and the Kotlin list have a lot in common: The Kingsford Manor Mystery Tea with Agatha Mystery on First Avenue The Ravine of Sorrows Among the Aliens Books to Read val booksToRead = listOf ( "Tea with Agatha", "Mystery on First Avenue", "The Ravine of Sorrows", "Among the Aliens", "The Kingsford Manor Mystery", ) Name of List Items First Last First Last In fact, let’s compare the two! Similarities between Libby's handwritten list and the Kotlin list. This code looks pretty similar to Libby’s handwritten list.

kotlin list to set

Val book5 = "The Kingsford Manor Mystery"Ĭreating a list of strings to represent titles of books.

kotlin list to set

Here’s what she wrote: val book1 = "Tea with Agatha" Libby has been learning to write Kotlin code in her spare time, so she also wanted to write this same list in Kotlin, and print all of the titles to the screen. The Kingsford Manor Mystery Tea with Agatha Mystery on First Avenue The Ravine of Sorrows Among the Aliens Books to Read Here are the titles that are currently on her list: A sheet of paper with a list of books that Libby wants to read. She’s always on the lookout for a great novel, so whenever someone tells her about a good book, she jots down the title on a list that she keeps on a sheet of paper. To learn about collections, let’s visit Libby, a bright young lady who’s always got a book nearby! Who Loves to Read Books? Writing Kotlin becomes so much more interesting once we start putting variables together in a way that we can work on them as a collection. So far, we’ve only worked with variables as individual values.










Kotlin list to set