swift 中的min(by:{}) 和max(by:{})

by:{$0 > $1} 决定了集合或数组从大到小排列
min取第一个元素
max 取最后一个元素

        let numbers = [3,2,4,1,5,7,6];
        let sortedNumbers = numbers.min(by:{$0 > $1});
        print(sortedNumbers ?? 0)
        ///log 7
        let numbers = [3,2,4,1,5,7,6];
        let sortedNumbers = numbers.max(by:{$0 > $1});
        print(sortedNumbers ?? 0)
        ///log 1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Create funky, impressive applications using Swift About This Book Learn Swift language features quickly, with playgrounds and in-depth examples Implement real iOS apps using Swift and Cocoapods Create professional video games with SpriteKit, SceneKit, and Swift Who This Book Is For This book is intended for those who want to learn to develop apps in Swift the right way. Whether you are an expert Objective-C programmer or new to this platform, you'll learn quickly, grasping the code of real-world apps to use Swift effectively. Prior experience in development for Apple devices would be helpful, but is not mandatory. What You Will Learn Explore the features of Swift Connect to a server and parse JSON data Take advantage of CocoaPods to use third-party libraries Utilize a clean and effective architecture to decrease complexity and speed up development Work with the most useful parts of the iOS SDK Build video games with SpriteKit and SceneKit Develop apps from start to finish Implement a weather app using fake data In Detail When Apple announced Swift at the WWDC, the iOS developer community became excited about the opportunities to improve the way in which they build iOS apps. Swift is a user-friendly language with a smooth learning curve; it is safe, robust, and flexible, and it introduces new ways to solve old problems. Swift by Example is a fast-paced, practical guide that shows you how to develop iOS apps using Swift. Through the development of six different apps, you'll learn how to use either the right feature of the language or the right tool to solve a given problem. By the end of the book you will be able to build well-designed apps, effectively use AutoLayout, and develop a video game. Table of Contents Chapter 1: Welcome to the World of Swift Chapter 2: A Memory Game in Swift Chapter 3: A TodoList App in Swift Chapter 4: A Pretty Weather App Chapter 5: Flappy Swift Chapter 6: Polishing Flappy Swift Chapter 7: Cube Runner Chapter 8: Completing Cube Runner
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值