Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Swift: Tuples and Functions
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Antonio Bello
November 16, 2014
Programming
74
0
Share
Swift: Tuples and Functions
SwiftCrunch, Krakow, Nov 16, 2014
Antonio Bello
November 16, 2014
More Decks by Antonio Bello
See All by Antonio Bello
Slices of Swift
jeden
1
64
From Learning to Mastering
jeden
4
150
Other Decks in Programming
See All in Programming
How to stabilize UI tests using XCTest
akkeylab
0
150
Java 21/25 Virtual Threads 소개
debop
0
310
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
110
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
380
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
450
Codex の「自走力」を高める
yorifuji
0
1.3k
ファインチューニングせずメインコンペを解く方法
pokutuna
0
220
存在論的プログラミング: 時間と存在を記述する
koriym
5
590
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
290
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.2k
AIと共にエンジニアとPMの “二刀流”を実現する
naruogram
0
110
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
520
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
110
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
990
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Deep Space Network (abreviated)
tonyrice
0
97
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
The Cult of Friendly URLs
andyhume
79
6.8k
Test your architecture with Archunit
thirion
1
2.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.8k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
320
Marketing to machines
jonoalderson
1
5.1k
Transcript
Swi$ Tuples'and'Func-ons Antonio&Bello Freelancer Code%Ar(st,%Polyglot%Developer @ant_bello
What's'a'tuple? A"tuple"it's"an"anonymous"struct • it$can$contain$mul,ple$heterogeneous$values • values$can$be$named$or$anonymous
Return'mul*ple'values func quotientAndRemainder(# dividend: Int, # divisor: Int) -> (quotient:
Int, remainder: Int) { let quotient = dividend / divisor return (quotient: quotient, remainder: dividend - divisor * quotient) } let result = quotientAndRemainder( dividend: 59, divisor: 13)
Pass$parameters$to$func/ons$and$ methods func quotientAndRemainder(# dividend: Int, # divisor: Int) ->
(quotient: Int, remainder: Int) { let quotient = dividend / divisor return (quotient: quotient, remainder: dividend - divisor * quotient) } let params = (dividend: 61, divisor: 7) let result = quotientAndRemainder(params)
Func%on'arguments'and'return' values'are'tuples A"func'on"with"no"parameters"takes"an"empty"tuple" ():" func doNothing() {...}
Func%on'arguments'and'return' values'are'tuples A"func'on"returning"Void"actually"returns"an"empty" tuple"(): func doSomething() -> () {...}
Func%on'arguments'and'return' values'are'tuples A"func'on"expec'ng"one"parameter"and"returning"a" single"value"actually: • takes'a'tuple'with'one'value • returns'a'tuple'with'one'value func doSomething(value:
Int) -> (Int) { ... }
Use$Cases
Use$cases Collec&ng)parameters)before) func&on)call Without'tuples ... var dividend = 29 ...
var divisor = 3 ... let result = quotientAndRemainder( dividend: dividend, divisor: divisor)
Use$cases Collec&ng)parameters)before) func&on)call With%tuples var params: (dividend: Int, divisor: Int)
... params.dividend = 29 ... params.divisor = 3 ... let immutableParams = params let result = quotientAndRemainder(immutable)
Important! A"tuple"passed"to"a"func/on"must"be"immutable let immutableParams = params let result = quotientAndRemainder(immutableParams)
Use$cases Buffering)func,on)calls Some%Code...
Thank&You code%@%github/jeden Antonio&Bello @ant_bello