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

Dean Kreseski
Dean Kreseski
2,418 Points

Keep getting this error "expected type" and cant figure out why

protocol VendingMachine { var selection: [VendingSelection] { get } var inventory: [VendingSelection: VendingItem] { get set } var amountDepostied: Double { get set }

init(inventory: [VendingSelection: VendingItem])
func vend(selection: VendingSelection, quantity: Int) throws
func deposit(_ amount: Double)
func item(forSelection selection: VendingItem) -> VendingItem?

}

this is the protocol where i declared the last function which i am using down here:

func item(forSelection selection: VendingItem) -> VendingItem? {
    return inventory[selection as! DictionaryIndex<_, _>]


}

}

during the tutorial it says use:

return inventory[selection] and then xcode told me to change it to what it is now