Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Vending Machine App in Swift 2.0 Using the Vending Machine Testing Out the Vending Machine

Why is quantity a double rather than an int?

There are no cases when you are going to return a fraction of a vending machine item, so why does Pasan use a double for quantity?

1 Answer

Anthony Ward
Anthony Ward
4,773 Points

Not sure if you figured this out yet. If so ignore

The initial file ("VendingInventory.plist") where he is pulling the raw data from has the quantity as a double (10.0...etc). Therefore for every instance of quantity thereafter he mirrored or matched the type.

Hope this helps.

Thanks!