Learn Courses My Dashboard

Level 9(14 days Challenge)

After running L9 challenge solution, i got this error as below

Error: L9 Challenge Solution.playgound:17:29: error: cannot convert value of type ‘Int’ to expected argument type ‘Double’ return totalWithTax/numPeople

Please help what I need to change

I ran into the same problem. I changed the number of people from an Int to a Double and it worked properly. From what I understand you can’t mix doubles and integers.

My thinking is that it makes sense to declare the number of people as an integer, as there can only be 1 / 2 / 3 / 4 / … people but not 1.2 people or similar. Using an Int will give you correct data.

To do some calculations with this Int number, you need to convert all numbers in this calculation to be the same (or similar?) type, for example doubles. But the conversation is really easy in SwiftUI.