# Chapter 2 mini exercise help

**URL:** <https://forums.kodeco.com/t/chapter-2-mini-exercise-help/121974>\
**Category:** Swift Apprentice\
**Created:** [October 7, 2020, 12:18am UTC](https://forums.kodeco.com/t/chapter-2-mini-exercise-help/121974 "2020-10-07T00:18:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaogden](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shaogden/32/81494_2.png) [@shaogden](https://forums.kodeco.com/u/shaogden)\
**Post date:** [October 7, 2020, 12:18am UTC](https://forums.kodeco.com/t/chapter-2-mini-exercise-help/121974/1 "2020-10-07T00:18:45Z")

</div>

Hello,

I am having problems with the 3 part of the question in the mini exercise.

1. Declare a constant tuple that contains three Int values followed by a Double. Use this to represent a date (month, day, year) followed by an average temperature for that date.
2. Change the tuple to name the constituent components. Give them names related to the data that they contain: month, day, year and averageTemperature.
3. In one line, read the day and average temperature values into two constants. You’ll need to employ the underscore to ignore the month and year.

so far I have let avgTemperature:(day: Int, month: Int, year: Int, averageTemperature: Double) = (9, 5, 1982, 77.6)  
What is meant by reading the day and average temperature values into two constants?

---

<div class="post-metadata">

**Author:** ![anthonyjattard](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/anthonyjattard/32/81494_2.png) [@anthonyjattard](https://forums.kodeco.com/u/anthonyjattard)\
**Post date:** [October 7, 2020, 8:59pm UTC](https://forums.kodeco.com/t/chapter-2-mini-exercise-help/121974/2 "2020-10-07T20:59:16Z")

</div>

Here is my code:

```
 // #1 - Declare a type alias for the myDate tuple    
typealias myDate = (Int, Int, Int, Double)

// #2 - Declare a constant tuple birthdate with my data giving them their names
let birthdate: myDate = (day: 12, month: 6, year: 1962, averageTemperature: 12.34)
print(birthdate)

// #3 Read the day and average temp and ignore the others using '_'
let (day, _ , _ , averageTemperature) = birthdate
print(day, averageTemperature) 

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![hvonweg](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hvonweg/32/105896_2.png) [@hvonweg](https://forums.kodeco.com/u/hvonweg)\
**Post date:** [October 15, 2020, 11:32am UTC](https://forums.kodeco.com/t/chapter-2-mini-exercise-help/121974/4 "2020-10-15T11:32:42Z")

</div>

Downloading the book, also contains the solutions for the challenges.

1. Declare a constant that contains three int values followed by a Double.  
let temperature = (10, 17, 2015, 15.7)
2. Change the tuple to name the components:  
let temperature = (month: 10, day: 17, year: 2015, averageTemperature: 15.7)
3. In one line, read the day and average temperature values into two constants  
let ( \_ , day, \_ , averageTemperature) = temperature

“What is meant by reading the day and average temperature values into two constants?”

In the line above you have two constants: day and averageTemperature. The values with underscore are ignored (in this case month and years).

This is equivalent to:  
**let** day = temperature.day  
**let** averageTemperature = temperature.averageTemperature

---

<div class="post-metadata">

**Author:** ![gdelarosa](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gdelarosa/32/109063_2.png) [@gdelarosa](https://forums.kodeco.com/u/gdelarosa)\
**Post date:** [October 19, 2020, 5:15pm UTC](https://forums.kodeco.com/t/chapter-2-mini-exercise-help/121974/5 "2020-10-19T17:15:53Z")

</div>

Welcome to the community @shaogden! Looks like there are a few helpful answers here. Are you still facing any issues with the mini exercise?

Best,  
Gina

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [March 22, 2021, 4:18pm UTC](https://forums.kodeco.com/t/chapter-2-mini-exercise-help/121974/6 "2021-03-22T16:18:48Z")

</div>

Closed on March 22, 2021, 4:18pm UTC

This topic was automatically closed after 166 days. New replies are no longer allowed.
