Created
September 19, 2023 14:59
-
-
Save brownsoo/54f4a4d2702fecd480664b1900d1d790 to your computer and use it in GitHub Desktop.
swift array extension to access a property of elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// [Page] 배열에서 movies 값만 모아 가져오기. | |
extension Array where Element == Page { | |
var movies: [String] { | |
flatMap { $0.movies } | |
} | |
} | |
/// Page 샘플 | |
struct Page { | |
let movies: [String] | |
let page: Int | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment