Programming in Swift: Functions & Types, Episode 14: forEach & map |

Find out how writing closures can help you handle collections with two common alternatives to for loops: forEach and map!

This is a companion discussion topic for the original entry at

Why does this code:
let salePrices = { $0 * 0.9)
results in β€œ6 times” message in the right tray, not 5 times?

This is probably only relevant to me, but the code

String(format: "%.2f", price)

only works if you also have

import Foundation

I’d managed to delete the import and Xcode was showing errors in the playground until I reinstated it