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

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 https://www.raywenderlich.com/28433240-programming-in-swift-functions-types/lessons/14

Why does this code:
let salePrices = price.map { $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