Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • substring function.. Commented Sep 29, 2015 at 17:03
  • @EricAya and other closers: This is not a duplicate of the linked question. In method call chains like [1,2,3].map({"Int(\($0))"}).joined(separator: ", ").last(x), substringWithRange and friends are useless. Commented Apr 7, 2017 at 11:49
  • See here for a solution that works in method chains, i.e. without an external reference to the string itself. (Commenting here because this is the top Google result.) Commented Apr 7, 2017 at 13:12
  • these days it's just .suffix(4) Commented Feb 26, 2024 at 14:50