Posts

Post not yet marked as solved
2 Replies
420 Views
Hey everyone,I'm learning about Swift tuples and wrote the following code...//Tuples //let temperature = (1, 23, 2020, 40.3) //let temperature = (month: 1, day: 23, year: 2020, avgTemp: 40.3) var temperature = (month: 1, day: 23, year: 2020, avgTemp: 42.3) let (_, day, _, avgTemp) = temperature temperature.avgTemp = 46.2 //the compiler acknowledges the temp change here by reading 46.2 let tempString = "Today's date is Janaury \(day)rd and the temperature is \(avgTemp) degrees."The result is not as expected.I was expecting "Today's date is Janaury 23rd and the temperature is 46.2 degrees."The compiler is reading "Today's date is Janaury 23rd and the temperature is 42.3 degrees."I'm not sure why this because I declared temperature as a variable and it reads avgTemp as '46.2' on line 6.Could someone please help with this?
Posted
by MJHiOS.
Last updated
.