当前位置:网站首页>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!")
边栏推荐
- 102. Sequence traversal of binary tree
- Sword finger offer06 Print linked list from end to end
- Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
- [combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
- Flutter: self study system
- Self made pop-up input box, input text, and click to complete the event.
- regular expression
- Shutter: about inheritedwidget
- error: expected reference but got (raw string)
- What is more elegant for flutter to log out and confirm again?
猜你喜欢

The future of cloud computing cloud native

ES6 standard

Shutter: overview of shutter architecture (excerpt)

1-2 project technology selection and structure

New features of ES6

Sword finger offer06 Print linked list from end to end

Pki/ca and digital certificate

Solve the problem of VI opening files with ^m at the end

Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!

Sword finger offer07 Rebuild binary tree
随机推荐
剑指Offer03. 数组中重复的数字【简单】
剑指Offer04. 二维数组中的查找【中等】
Write a simple nodejs script
Sword finger offer04 Search in two-dimensional array [medium]
Shutter: add gradient stroke to font
Record your vulnhub breakthrough record
Dart: view the dill compiled code file
Self made pop-up input box, input text, and click to complete the event.
记录自己vulnhub闯关记录
(construction notes) grasp learning experience
Integer int compare size
Introduction to concurrent programming (II)
Flutter: about monitoring on flutter applications
How to deploy web pages to Alibaba cloud
Shutter widget: centerslice attribute
Summary of development issues
elastic_ L01_ summary
regular expression
Sword finger offer07 Rebuild binary tree
Sword finger offer06 Print linked list from end to end