SlideShare a Scribd company logo
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
func serialization() -> String {
var serialized = ""
serialized += String(SerializedValue(turn: turn))
serialized += "n"
serialized += String(SerializedValue(board: board))
serialized += "n"
return serialized
}
@Serialization
func serialization() -> String {
turn
board
}
_Function Builders in Swift #love_swift
@_functionBuilder
enum Sample {
//
}
@Sample
func execute() -> Component
{
// DSL
}
init(@Sample body:()->Component) {
// DSL
}
_Function Builders in Swift #love_swift
1. buildExpression(_: Expression) -> Component
2. buildBlock(_: Component ...) -> Component
3. buildDo(_: Component ...) -> Component
buildEither(first: Component) -> Component
buildEither(second: Component) -> Component
buildFunction(_: Components...) -> Return
buildOptional(_: Component?) -> Component
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
static func buildBlock(
_ a: Component, _ b: Component) -> Component {
}
static func buildBlock(_ a: Int, _ b: String, _ c: Bool) -> Component {
}
static func buildBlock(_ components: Component...) -> Component {
}
static func buildBlock(_ a: Int, _: Void) -> Component {
}
static func buildExpression() -> Component {
}
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
static func buildExpression(_ expression: Expression) -> Component
{
}
static func buildExpression(_: Void) -> Component {
}
static func buildExpression(_: Never) -> Component {
}
static func buildExpression(_: Never) -> Component {
}
static func buildExpression<T>(_ expression: T) -> T {
return expression
}
Do
_Function Builders in Swift #love_swift
static func buildDo(_ component: Component) -> Component {
}
If
_Function Builders in Swift #love_swift
if … {
①
}
else {
②
}
BLOCK
2nd1st
if … {
①
}
else if {
②
}
else {
③
}
2nd1st
BLOCK
2nd1st
2nd1st
if … {
①
}
else if … {
②
}
else if … {
③
}
else {
④
}
BLOCK
2nd1st
2nd1st
if … {
①
}
else if … {
②
}
else if … {
③
}
else if … {
④
}
else {
⑤
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
1st 2nd
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
1st 2nd
1st 2nd
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
1st 2nd
1st 2nd 1st 2nd
BLOCK
1st 2n 1st
2nd
1st 2n
1st
2n
1st 2n
1st 2n 1st 2n
1st
2nd
BLOCK
1st 2n 1st
2nd
1st 2n
1st
2n
1st 2n
1st 2n 1st 2n
1st
2nd
2nd1st
BLOCK
1st 2n 1st
2nd
1st 2n
1st
2n
1st 2n
1st 2n 1st 2n
1st
2nd
2nd1st
1st 2n
if … {
①
}
else {
if … {
②
}
else {
③
}
}
BLOCK
2nd1st
2nd1st
BLOCK
_Function Builders in Swift #love_swift
_Function Builders in Swift #love_swift
Build Block
Build ExpressionBuild Expression
Build DoBuild Do
Build Function
Build If
Build Optional
Build Block
Build DoBuild Either
Build Block
_Function Builders in Swift #love_swift

More Related Content

PDF
Javascript & Ajax Basics
PPT
Class ‘increment’
KEY
Object-Oriented Javascript
PDF
Swift で JavaScript 始めませんか? #iOSDC
PDF
Cycle.js: Functional and Reactive
PDF
Elm: give it a try
PDF
Composition in JavaScript
ODP
EcmaScript 6
Javascript & Ajax Basics
Class ‘increment’
Object-Oriented Javascript
Swift で JavaScript 始めませんか? #iOSDC
Cycle.js: Functional and Reactive
Elm: give it a try
Composition in JavaScript
EcmaScript 6

What's hot (20)

PDF
PPTX
Template syntax in Angular 2.0
PPTX
Type Driven Development with TypeScript
PPTX
The State of JavaScript
PPTX
Angular 2 Architecture
PPTX
Groovy grails types, operators, objects
KEY
jrubykaigi2010-lt-rubeus
PDF
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
PDF
Hidden Gems in Swift
PPTX
Functional programming principles
PDF
Chaining and function composition with lodash / underscore
PDF
4. Обработка ошибок, исключения, отладка
PPTX
Oop presentation
PPTX
The next step, part 2
PDF
Workshop 5: JavaScript testing
ZIP
PPTX
Component lifecycle hooks in Angular 2.0
PDF
JavaScript Fundamentals with Angular and Lodash
PDF
Lodash js
PPTX
Operator overloading2
Template syntax in Angular 2.0
Type Driven Development with TypeScript
The State of JavaScript
Angular 2 Architecture
Groovy grails types, operators, objects
jrubykaigi2010-lt-rubeus
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Hidden Gems in Swift
Functional programming principles
Chaining and function composition with lodash / underscore
4. Обработка ошибок, исключения, отладка
Oop presentation
The next step, part 2
Workshop 5: JavaScript testing
Component lifecycle hooks in Angular 2.0
JavaScript Fundamentals with Angular and Lodash
Lodash js
Operator overloading2
Ad

More from Tomohiro Kumagai (20)

PDF
最近気づいた勉強法 — 勉強会開催の習慣化 #yumemi_grow
PDF
Swift 所有権 要諦 #ゆるちとせ
PDF
Property Wrappers の特徴を眺める #swiftzoomin
PDF
みんなで Swift 復習会 GO! in "Swift Days Fukuoka" – 12nd′ オープニング&資料
PDF
みんなで Swift 復習会
GO! in 札幌 – 10th′′
PDF
イニシャライザー Part 2.5 #hakataswift
PDF
ニコニコ超会議・文化の交差点 #techpub #ニコニコ超会議 #さくらシンデレラ
PDF
Swift クラスのイニシャライザー #devsap
PDF
iOSCon 2019 in London #ioscon #love_swift
PDF
Around the 変数 let #love_swift
PDF
もくもく執筆会 #技術同人誌再販Night
PDF
みんなで Swift 復習会 GO! in 岩手 – 9th′
PDF
macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswift
PDF
みんなで Swift 復習会 GO! in 福岡 – 8th′ #minna_de_swift
PDF
Getting Started with Attending iOSCon in London 高画質・追記版 #love_swift #ioscon
PDF
みんなで Swift 復習会
GO! in 京都 – 6th′
PDF
みんなで Swift 復習会 GO! in 福岡 – 5th′
PDF
勉強会の東京外開催の気持ち #yuru_bounen2017
PDF
みんなで Swift 復習会 GO! in 福岡・発表資料
PDF
Protocol-Oriented Integers に想うジェネリックプログラミングの未来
最近気づいた勉強法 — 勉強会開催の習慣化 #yumemi_grow
Swift 所有権 要諦 #ゆるちとせ
Property Wrappers の特徴を眺める #swiftzoomin
みんなで Swift 復習会 GO! in "Swift Days Fukuoka" – 12nd′ オープニング&資料
みんなで Swift 復習会
GO! in 札幌 – 10th′′
イニシャライザー Part 2.5 #hakataswift
ニコニコ超会議・文化の交差点 #techpub #ニコニコ超会議 #さくらシンデレラ
Swift クラスのイニシャライザー #devsap
iOSCon 2019 in London #ioscon #love_swift
Around the 変数 let #love_swift
もくもく執筆会 #技術同人誌再販Night
みんなで Swift 復習会 GO! in 岩手 – 9th′
macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswift
みんなで Swift 復習会 GO! in 福岡 – 8th′ #minna_de_swift
Getting Started with Attending iOSCon in London 高画質・追記版 #love_swift #ioscon
みんなで Swift 復習会
GO! in 京都 – 6th′
みんなで Swift 復習会 GO! in 福岡 – 5th′
勉強会の東京外開催の気持ち #yuru_bounen2017
みんなで Swift 復習会 GO! in 福岡・発表資料
Protocol-Oriented Integers に想うジェネリックプログラミングの未来
Ad

Recently uploaded (20)

PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Introduction to Artificial Intelligence
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
System and Network Administration Chapter 2
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Essential Infomation Tech presentation.pptx
Odoo POS Development Services by CandidRoot Solutions
Introduction to Artificial Intelligence
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
System and Network Administration Chapter 2
VVF-Customer-Presentation2025-Ver1.9.pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Upgrade and Innovation Strategies for SAP ERP Customers
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
ai tools demonstartion for schools and inter college
CHAPTER 2 - PM Management and IT Context
Odoo Companies in India – Driving Business Transformation.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Which alternative to Crystal Reports is best for small or large businesses.pdf

_Function Builders in Swift #love_swift