Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
初めてのターミナルプログラム
Elvis Shi
March 09, 2018
Programming
0
1.5k
初めてのターミナルプログラム
Elvis Shi
March 09, 2018
Tweet
Share
More Decks by Elvis Shi
See All by Elvis Shi
偏見と妄想で語るスクリプト言語としての Swift / Swift as a Scripting Language
lovee
2
270
danger-swift-kantoku
lovee
1
130
Decimal、正しく使ってる? / Are you using Decimal correctly?
lovee
4
280
A story about me trying to make a router that manages when, how and which view to transit in a SwiftUI app
lovee
1
160
M1チップの脆弱性M1raclesを読み解く / About the vulnerability on M1 chip called M1racles
lovee
1
790
Demystify SwiftUI 要約 / Summary of Demystify SwiftUI
lovee
3
350
いいから `!` を使え! / Shut up and use `!` !
lovee
11
3.4k
SwiftUIにおける依存性逆転原則の戦略 / A strategy to import Dependency-Inversion-Principle in SwiftUI apps
lovee
3
430
CGAffineTransform はどう動いてるのか?〜Swift エンジニアのための線形代数〜 / How does CGAffineTransform work? ~A linearity lesson for Swift engineers~
lovee
0
220
Other Decks in Programming
See All in Programming
Explore Java 17 and beyond
josepaumard
3
650
Enterprise Angular: Frontend Moduliths with Nx and Standalone Components @jax2022
manfredsteyer
PRO
0
300
LegalForceの契約データを脅かすリスクの排除と 開発速度の向上をどうやって両立したか
aibou
0
140
Monadic Java
mariofusco
4
260
코드 품질 1% 올리기
pluu
1
990
クリエイティブ系のウェブサイト制作で役立つCSS技法 / CSS for develop creative website
clockmaker
2
1.6k
Loom is Blooming
josepaumard
3
540
よりUXに近いSLI・SLOの運用による可用性の再設計
kazumanagano
3
630
Android Architecture Design With Koin
agiuliani
0
230
質とスピード(2022春版、質疑応答用資料付き) / Quality and Speed 2022 Spring Edition
twada
PRO
29
18k
Becoming an Android Librarian
skydoves
3
460
バンドル最適化マニアクス at tfconf
mizchi
3
2.3k
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
57
3.8k
GraphQLの誤解/rethinking-graphql
sonatard
24
6.2k
How To Stay Up To Date on Web Technology
chriscoyier
780
250k
Gamification - CAS2011
davidbonilla
75
3.9k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
11
4.6k
Web development in the modern age
philhawksworth
197
9.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
19
1.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
638
52k
How GitHub Uses GitHub to Build GitHub
holman
465
280k
Infographics Made Easy
chrislema
233
17k
Making Projects Easy
brettharned
98
4.3k
Rails Girls Zürich Keynote
gr2m
86
12k
Transcript
ॳΊͯͷ λʔϛφϧϓϩάϥϜ forUSZ4XJGU5PLZP"GUFSUBMLT
var employedBy = "YUMEMI Inc." var job = "iOS Developer"
var favoriteLanguage = "Swift" var twitter = "@lovee" var qiita = "lovee" var github = "el-hoshino" var additionalInfo = """ ΏΔΏΔΩϟϯϓ͘͘ձɺࢀՃऀืूத """ class Me: Developable, Talkable { }
༷ʑͳλʔϛφϧϓϩάϥϜ ▸ QJOH ▸ CSFX ▸ HJU ▸ LVSJ ▸
IBOBLP ▸ FSVUBTP 1kuri: https://github.com/bannzai/Kuri 2hanako: https://github.com/el-hoshino/hanako 3erutaso: https://github.com/sgymtic/sl
ࣗ࡞Ζ͏
·ͣੈքʹ ѫࡰ͠Α͏
9DPEF ʷ 4XJGU
None
import Foundation print("Hello, World!")
import Foundation print("Hello, World!")
import Foundation print("Hello, World!")
$ cd {path/to/project/dir} $ xcodebuild $ cp build/Release/{app_name} /usr/local/bin $
{app_name} hello, world! 今回は簡単なプログラムなので Xcode 使わずに `swiftc` で ビルドしてもいいけど まあいいや
Ͷɺ؆୯Ͱ ͠ΐʁ
$ cd {path/to/project/dir} $ xcodebuild $ cp build/Release/{app_name} /usr/local/bin $
{app_name} hello, world! コマンド引数って どうやって取るんだろ
import Foundation CommandLine.arguments: [String]
None
import Foundation let candidates = Array(CommandLine.arguments.dropFirst()) var outputs: [String] =
[] output: while let random = candidates.random { print(random) outputs.append(random) outputs.keepLast(candidates.count) if outputs == candidates { print(outputs.joined(separator: " ") .appending("!")) break output } }
import Foundation extension Array { var random: Element? { guard
self.isEmpty == false else { return nil } let randomIndex = arc4random_uniform(UInt32(self.count)) return self[Int(randomIndex)] } mutating func keepLast(_ n: Int = 1) { guard self.count > n else { return } let removingElementsCount = self.count - n self.removeFirst(removingElementsCount) } }
%&.0