0

This question is based upon the excellent answer here: https://stackoverflow.com/a/29835826/642697

var asciiValues: [UInt8] { compactMap(\.asciiValue) }

I'm hoping someone can explain the "\" notation and perhaps point me at the documentation for it as further reading?

The snippet below is how I have seen/used compactMap before. Are they the same?

var asciiValues: [UInt8] { compactMap { $0.asciiValue }}
Andy P
  • 667
  • 7
  • 14
  • 1
    `KeyPath`: https://docs.swift.org/swift-book/ReferenceManual/Expressions.html – Larme Dec 14 '21 at 11:52
  • 1
    https://www.biteinteractive.com/swift-5-2-keypaths-get-a-promotion/ – matt Dec 14 '21 at 11:53
  • Thanks for the help both - exactly what i needed. – Andy P Dec 14 '21 at 12:00
  • 2
    Not my vote, but a search for "backslash" in this tag leads to https://stackoverflow.com/questions/52543502/swift-what-does-backslash-dot-mean, which is quite close to what you are looking for. – Martin R Dec 14 '21 at 12:16
  • @MartinR I did try a search on the swift tag, but didn't see that one. I'm more than happy if people want to vote close as a duplicate of that question – Andy P Dec 14 '21 at 12:26

0 Answers0