Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Kotlin Standard Library Cookbook

You're reading from   Kotlin Standard Library Cookbook Master the powerful Kotlin standard library through practical code examples

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788837668
Length 242 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Samuel Urbanowicz Samuel Urbanowicz
Author Profile Icon Samuel Urbanowicz
Samuel Urbanowicz
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Ranges, Progressions, and Sequences 2. Expressive Functions and Adjustable Interfaces FREE CHAPTER 3. Shaping Code with Kotlin Functional Programming Features 4. Powerful Data Processing 5. Tasteful Design Patterns Adopting Kotlin Concepts 6. Friendly I/O Operations 7. Making Asynchronous Programming Great Again 8. Best Practices for the Android, JUnit, and JVM UI Frameworks 9. Miscellaneous 10. Other Books You May Enjoy

Building strings based on dataset elements

Sometimes, we face the problem of generating text based on collections' elements. This is where the Iterable.joinToString() extension function can help. For example, we can consider working on an email-message-forwarding feature. When a user clicks the forward button, the original message's body text is concatenated, with the prefix looking something like this:

<br/>
<p>---------- Forwarded message ----------</p>
<p>
From: johny.b@gmail.com <br/>
Date: 14/04/2000 <br/>
Subject: Any plans for the evening?<br/>
To: natasha@gmail.com, barbra@gmail.com<br/>
</p>

In this recipe, we are going to implement a function that is going to generate the recipients' string, for example:

To: natasha@gmail.com, barbra@gmail.com</br>

For a given list of Address type objects, it is defined...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime