Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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