Swift 4 Recipes by Yanis Zafirópulos

Swift 4 Recipes by Yanis Zafirópulos

Author:Yanis Zafirópulos
Language: eng
Format: epub
ISBN: 9781484241820
Publisher: Apress


Let’s see...print("Item at index 1: \(item)")

How It Works

To get a particular element at a specific index of a tuple, we may use its index.Item at index 1: two

8.38 Get tuple element by pattern matching

Problem

I want to get a specific tuple element by matching against a given pattern.

Solution

First, we initialize a test tuple.let tuple = ("one", "two", "three")

We want the item at index: 1 (the second element) so that we can safely ignore everything else.let (_, item, _) = tuple



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.