#70: some vs any in Swift

A quick mental model: some means “one concrete type, hidden from you”, while any means “a box that can hold values of any conforming type”.

func makeID() -> some Hashable { 42 }
let value: any Hashable = 42

With some, the implementation chooses a concrete type and sticks to it. With any, the concrete type can vary at runtime.

That simple distinction explains most of the behavior you will see in practice.


I'm also on Twitter and GitHub.

Subscribe via RSS.