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
Ankoは甘くて美味しい〜Ankoに見るKotlinの表現力〜 #gunosybeer
Search
Taro Nagasawa
December 08, 2015
Programming
1.7k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ankoは甘くて美味しい〜Ankoに見るKotlinの表現力〜 #gunosybeer
エムスリー x Gunosy Beer bash!で発表した資料です
Taro Nagasawa
December 08, 2015
More Decks by Taro Nagasawa
See All by Taro Nagasawa
Android開発者のための Kotlin Multiplatform入門
ntaro
0
1.8k
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
2.4k
#Ubie 狂気の認知施策と選考設計
ntaro
14
14k
UbieにおけるサーバサイドKotlin活用事例
ntaro
1
1.2k
KotlinでSpring 完全理解ガイド #jsug
ntaro
6
3.7k
Kotlinでサーバサイドを始めよう!
ntaro
1
1.1k
Androidからサーバーサイドまで!プログラミング言語 Kotlinの魅力 #devboost
ntaro
5
3.1k
Kotlin Contracts #m3kt
ntaro
4
4.4k
How_to_Test_Server-side_Kotlin.pdf
ntaro
1
590
Other Decks in Programming
See All in Programming
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
430
AmebaブログはKMPから卒業します
kmars0605
0
190
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
790
phperだってパンチカードでコーディングしたい
o0h
PRO
0
330
golang-bob.pdf
iwatsukayura
0
130
Agents on Rails - Rails at Scale 2026
irinanazarova
0
560
Jetpack Compose Mechanisms
skydoves
3
820
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.6k
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
ChromeでローカルLLM
ryu1013
0
140
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
910
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
Skip the Path - Find Your Career Trail
mkilby
1
260
Product Roadmaps are Hard
iamctodd
55
13k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Mind Mapping
helmedeiros
1
400
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
Transcript
Ankoͯ͘ඒຯ͍͠ ʙAnkoʹݟΔKotlinͷදݱྗʙ ΤϜεϦʔY(VOPTZ#FFSCBTIʂ HVOPTZCFFS ᖒଠ!OHTX@UBSP
ࣗݾհ w ᖒଠ!OHTX@UBSP w "OESPJEΤϯδχΞ w ,PUMJOΤϰΝϯδΣϦετ ࣗশ w
ࡀɺֈ࠲ɺͱ͕େ͖
Kotlinͱ w +FU#SBJOT։ൃͷ+7.ݴޠ w "OESPJEαϙʔτ w ൃදɺ·ͩϕʔλ൛ w "OESPJE+BWB͔Β,PUMJOΓ͑ϫϯνϟϯ w
࠷ۙɺհهࣄ͕ཚཱͯ͠ΔͷͰͦͪΒࢀর
Ankoͱ w ,PUMJOͰهड़͞Εͨ"OESPJEϥΠϒϥϦ w +FU#SBJOT։ൃʢઆಘྗɾ҆৺ײ͕͋Δʣ w ओʹ6*ΛΈཱͯΔ%4-
UIΛΈཱͯΔDSL w جຊతʹ"OESPJEͰ9.-Ͱ6*Λදݱ͢Δ w ࠶ར༻ੑɺ҆શੑɺύϑΥʔϚϯεͷ໘Ͱෆར w ͱ͍͑ίʔυͰ໋ྩతʹ6*Λߏங͢Δͷμα Πʢ4XJOHΈ͍ͨͳΠϝʔδʣ w %4-Ͱએݴతʹ6*Λߏங͢Δ
ʢ+BWB'94DSJQUΈ͍ͨͳΠϝʔδʣ
ඪ४APIͰΰϦΰϦΔ val act = this! val layout = LinearLayout(act)! layout.orientation
= LinearLayout.VERTICAL! val name = EditText(act)! val button = Button(act)! button.text = "Say Hello"! button.setOnClickListener {! Toast.makeText(act,! "Hello, ${name.text}!”,! Toast.LENGTH_SHORT).show()! }! layout.addView(name)! layout.addView(button)
AnkoͰDSL verticalLayout {! val name = editText()! button("Say Hello") {!
onClick {! toast("Hello, ${name.text}!”)! }! }! }
Ͳ͏ಈ͍͍ͯΔͷ͔ There is no .
ϥϜμࣜ Lambda Expression
ߴ֊ؔͱϥϜμࣜ // ҾʹAΛऔͬͯBΛฦؔ͢fΛҾʹऔΔؔ! fun <A, B> convert(target: A,! f: (A)->B)
= f(target)! ! convert(1, { x: Int -> x * 2 }) //=> 2! convert(2, { x -> x * 2}) //=> 4! convert(3, { it * 2 }) //=> 6! convert(4) { it * 2 } //=> 8
֦ுؔ Extension Function
֦ுؔ fun String.hello() = “Hello, $this”! ! “world”.hello() //=> “Hello,
world”
֦ுؔ × ϥϜμࣜ fun <A, B> A.convert(f: (A)->B) = f(this)!
! 3.convert({ x: Int -> x * 2}) //=> 6! 3 convert { it * 2 } //=> 6
Anko class MainActivity : Activity() {! override fun onCreate(savedInstanceState: Bundle?)
{! super.onCreate(savedInstanceState)! ! verticalLayout {! val name = editText()! button("Say Hello") {! onClick { toast("Hello, ${name.text}!") }! }! }! }! }
Anko class MainActivity : Activity() {! override fun onCreate(savedInstanceState: Bundle?)
{! super.onCreate(savedInstanceState)! ! verticalLayout {! val name = editText()! button("Say Hello") {! onClick { toast("Hello, ${name.text}!") }! }! }! }! } "DUJWJUZͷ֦ுؔ UIJT͕লུ͞ΕͯΔ
Anko class MainActivity : Activity() {! override fun onCreate(savedInstanceState: Bundle?)
{! super.onCreate(savedInstanceState)! ! verticalLayout {! val name = editText()! button("Say Hello") {! onClick { toast("Hello, ${name.text}!") }! }! }! }! } ͜ͷUIJT WFSUJDBM-BZPVU
Anko class MainActivity : Activity() {! override fun onCreate(savedInstanceState: Bundle?)
{! super.onCreate(savedInstanceState)! ! this.verticalLayout {! val name = this.editText()! this.button(“Say Hello") {! onClick { toast("Hello, ${name.text}!") }! }! }! }! } UIJT͕ผͷͷΛࢦ͢ Կނ͔ʁ
֦ுؔΛҾʹऔΔߴ֊ؔ class Builder { fun foo() {} }! ! fun
build(f: Builder.() -> Unit) {! Builder().f()! }! ! build {! foo()! }
Կ͕خ͍͠ͷ͔ verticalLayout {! button(“foo”)! verticalLayout {! button(“bar”)! verticalLayout {! button(“baz”)!
}! }! }
Կ͕خ͍͠ͷ͔ verticalLayout {! button(“foo”)! verticalLayout {! button(“bar”)! verticalLayout {! button(“baz”)!
}! }! } ֊ߏΛදݱͰ͖Δ ϝιουͷείʔϓ ΛߜΕΔ ܕ҆શ OVMM҆શ
XMLͰฤू͢Δͱ ը໘ϓϨϏϡʔ ݟΕΔ͡ΌΜʁ
None
ͦΕɺAnkoͰ Ͱ͖·͢ʂ
None
Θͳ͍खͳ͍
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠