News for hackers. Stuff that matters.
Re:What’s New in Swift 5.2 by Tainnor on Friday February 07, 2020 @08:04PM (#22272904)
This is because Swift is quite low-level when it comes to storage etc., so [0..<n] returns an ArraySlice.

However, this has nothing to do with generics.If you're willing to sacrifice performance, you could easily write

  extension Array {
      func take(_ n: Int) -> [Element] {
          Array(self[0..<n])
      }
  }

There are no comments on this comment yet.