Adding firstAs() to Sequence

Yeah, seeing those two side-by-side indicates that perhaps firstMap isn't the best name. I picked it because of its symmetry with first(where:) and compactMap(_:).

I believe this is worth adding to the Standard Library, because it meets The Law of Soroush:

If an extension meets any one of the following four criteria, it deserves to exist:

  1. Does it increase expressivity?
  2. Does it decrease noise?
  3. Does it include a performance optimization?
  4. Does it belong on every instance of the type?
1 Like