当前位置:网站首页>Do you feel like you've learned something and forgotten it?
Do you feel like you've learned something and forgotten it?
2022-07-03 12:34:00 【iWillook】
extension Int {
func repetitions(task: () -> Void) {
for _ in 0..<self {
task()
}
}
mutating func square() {
self = self * self
}
subscript(digitIndex: Int) -> Int {
var decimalBase = 1
for _ in 0..<digitIndex {
decimalBase *= 10
}
return (self / decimalBase) % 10
}
enum Kind {
case negative, positive, zero
}
var kind: Kind {
switch self {
case 0:
return .zero
case let x where x > 0:
return .positive
default:
return .negative
}
}
}
var i = 0
9.repetitions {
print(987239847[i])
i += 1
}
var someInt = 3
someInt.square()
func printIntegerKinds(_ numbers: [Int]) {
for number in numbers {
switch number.kind {
case .negative:
print("- ", terminator: "")
case .zero:
print("0 ", terminator: "")
case .positive:
print("+ ", terminator: "")
}
}
print("")
}
printIntegerKinds([3, 19, -27, 0, -6, 0, 7])
Excerpt From: Apple Inc. “The Swift Programming Language (Swift 5.3).” Apple Books. https://books.apple.com/us/book/the-swift-programming-language-swift-5-3/id881256329
边栏推荐
- Wechat applet - basic content
- Lambda expression
- Togaf certification self-study classic v2.0
- 102. Sequence traversal of binary tree
- 1-1 token
- error: expected reference but got (raw string)
- 145. Post order traversal of binary tree
- [combinatorics] permutation and combination (example of permutation and combination)
- DEJA_ Vu3d - cesium feature set 053 underground mode effect
- Computer version wechat applet full screen display method, mobile phone horizontal screen method.
猜你喜欢

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

The future of cloud computing cloud native

Summary of development issues

剑指Offer07. 重建二叉树

Shutter widget: centerslice attribute

Display time with message interval of more than 1 minute in wechat applet discussion area

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

Cloud Computing future - native Cloud

Flutter 退出登录二次确认怎么做才更优雅?

雲計算未來 — 雲原生
随机推荐
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
node的ORM使用-Sequelize
ES6新特性
Dart: view the dill compiled code file
Alibaba is bigger than sending SMS (user microservice - message microservice)
temp
Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
[embedded] - Introduction to four memory areas
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
How to deploy web pages to Alibaba cloud
Oh my Zsh + TMUX installation
Redis
写一个简单的nodejs脚本
Shutter: about inheritedwidget
Idea packages the web project into a war package and deploys it to the server to run
Use of atomicinteger
Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
剑指Offer06. 从尾到头打印链表
剑指Offer03. 数组中重复的数字【简单】
公纵号发送提示信息(用户微服务--消息微服务)