当前位置:网站首页>Swift return type is a function of function
Swift return type is a function of function
2022-07-03 12:34:00 【iWillook】
//
// main.swift
// Ultimate
//
// Created by Mewlan Musajan on 3/5/21.
//
import Foundation
func stepForward(_ input: Int) -> Int {
return input + 1
}
func stepBackward(_ input: Int) -> Int {
return input - 1
}
func chooseStepFunction(_ backward: Bool) -> (Int) -> Int {
return backward ? stepBackward : stepForward
}
var currentValue = 3
let moveNearerToZero = chooseStepFunction(currentValue > 0)
print("Counting to zero:")
while currentValue != 0 {
print("\(currentValue)...")
currentValue = moveNearerToZero(currentValue)
}
print("zero!")
边栏推荐
- 手机号码变成空号导致亚马逊账号登陆两步验证失败的恢复网址及方法
- Unicode查询的官方网站
- ImportError: No module named examples. tutorials. mnist
- 剑指Offer06. 从尾到头打印链表
- 实现验证码验证
- [combinatorics] permutation and combination (example of permutation and combination)
- How to deploy web pages to Alibaba cloud
- flinksql是可以直接客户端建表读mysql或是kafka数据,但是怎么让它自动流转计算起来呢?
- lambda与匿名内部类的区别
- temp
猜你喜欢

2.8 overview of ViewModel knowledge

Sword finger offer10- I. Fibonacci sequence

【附下载】密码获取工具LaZagne安装及使用

Shutter widget: centerslice attribute

Sword finger offer09 Implementing queues with two stacks

Day 1 of kotlin learning: simple built-in types of kotlin

Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)

剑指Offer03. 数组中重复的数字【简单】

剑指Offer10- I. 斐波那契数列

2.7 overview of livedata knowledge points
随机推荐
在网上炒股开户可以吗?资金安全吗?
Jsup crawls Baidu Encyclopedia
Flutter 退出登录二次确认怎么做才更优雅?
Redis
Sqoop1.4.4原生增量导入特性探秘
Day 1 of kotlin learning: simple built-in types of kotlin
Nodejs+Express+MySQL实现登陆功能(含验证码)
Record your vulnhub breakthrough record
20. Valid brackets
Solve the problem of VI opening files with ^m at the end
01_ Using the concurrent tool class library, is thread safety safe
Adult adult adult
Applet wxss introduction
1-2 project technology selection and structure
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
[ManageEngine] the role of IP address scanning
adb push apk
Computer version wechat applet full screen display method, mobile phone horizontal screen method.
Flutter: about monitoring on flutter applications
2021 autumn Information Security Experiment 1 (password and hiding technology)