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 an error that says "expected type" when I try to use the item function.

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 function

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


}

}

it used to be: return inventory[selection] but then it recommends I change it to what it says currently.

on the return inventory line is where I am getting the "expected type" error