Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Swift: Tuples and Functions
Search
Antonio Bello
November 16, 2014
Programming
81
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
78
From Learning to Mastering
jeden
4
170
Other Decks in Programming
See All in Programming
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
120
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
140
Seven New Principles of Software Engineering
yegor256
0
450
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
230
Event is what happens
moro
2
3.6k
SODA - FACT BOOK(JP)
sodainc
1
40k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
330
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
14
11k
Crash Auto Pipelines
veronikapj
1
360
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
1.2k
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
150
AmebaブログはKMPから卒業します
kmars0605
0
320
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
300
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
370
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
280
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
970
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Evolving SEO for Evolving Search Engines
ryanjones
0
350
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
300
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
570
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