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
「var禁止」禁止
Search
RyotaMurohoshi
February 20, 2016
Technology
0
10
「var禁止」禁止
2016/02/20 Hokuriku Comm CampのLTで発表した際のプレゼンテーションスライドです。
RyotaMurohoshi
February 20, 2016
Tweet
Share
More Decks by RyotaMurohoshi
See All by RyotaMurohoshi
Unityの合同同人誌や合同商業誌を書いてる僕は感想やレビューや評価が欲しい
ryotamurohoshi
0
420
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
650
Odin Validationはいいぞ!
ryotamurohoshi
2
880
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.3k
Unityでも、新しいC#
ryotamurohoshi
0
1.2k
Riderはいいぞ!
ryotamurohoshi
1
3.3k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.3k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
36k
ImportedLinqのススメ
ryotamurohoshi
0
1.3k
Other Decks in Technology
See All in Technology
株式会社ログラス − エンジニア向け会社説明資料 / Loglass Comapany Deck for Engineer
loglass2019
3
32k
Storage Browser for Amazon S3
miu_crescent
1
290
Qiita埋め込み用スライド
naoki_0531
0
5.3k
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
130
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
830
Wantedly での Datadog 活用事例
bgpat
2
680
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
1.4k
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
290
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
140
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
120
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
320
組み込みアプリパフォーマンス格闘記 検索画面編
wataruhigasi
1
140
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Six Lessons from altMBA
skipperchong
27
3.5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
4 Signs Your Business is Dying
shpigford
182
21k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
It's Worth the Effort
3n
183
28k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Transcript
ʮvarېࢭʯېࢭ @RyotaMurohoshi 2016/02/20()(Hokuriku(ComCamp(2016(powered(by(MVPs
C#Λॻ͍͍ͯͯɺ͜Μͳ͜ͱ ݴΘΕͨ͜ͱͳ͍Ͱ͔͢ʁ
ʮvar͏ͷېࢭͳʂʯ
ࣗݾհ @RyotaMurohoshiͰ͢
ઍ༿ݝദࢢ͔Β͖·ͨ͠
࣮Ո৽ׁݝͰ͢
UnityΫϥελ͔Β͖·ͨ͠
Ξϯέʔτʂ
C#er%!? ͬͨ͜ͱ͋Δਓʂʁ
ʮvarʯ͕Կ͔Θ͔Δ$!? C#erͳΒΘ͔ΔΑͶʂʁ
Javaॻ͘Αͬͯͻͱ$!?
ʮvarېࢭʯݴΘΕͨ͜ͱ͋Δ$!? ͭΒ͍orz
͋Γ͕ͱ͏͍͟͝·ͨ͠
C#ͷศརͳݴޠػೳͷʮvarʯ ੈͷதʹɺͦΕΛݏ͏ɾΘͳ͍ਓ͕͍ΔΒ͍͠Ͱ͢
ͦΕΛΘͳ͍ͳΜͯͱΜͰͳ͍
ʮvarʯͪΌΜͱ͓͏ͥ
ʮvarېࢭʯېࢭ
ͦΕͰʮvarېࢭʯͬͯݴΘΕͨ࣌ͷ ͍͍ײ͡ͷฦ͠Λߟ͍͖͑ͯ·͠ΐ͏ʂ
έʔε1 ʮvarɺܕ͕ͳͯ͘ΩϞ͍͔Βېࢭͳʂʯ ͬͯݴΘΕΔ
έʔε1ͷݪҼ varΛͪΌΜͱཧղ͍ͯ͠ͳ͍
ʮvarͱʁʯ ҉తʹܕࢦఆ͞ΕΔϩʔΧϧม from%MSDN%h+ps:/ /msdn.microso5.com/ja8jp/library/bb384061.aspx
҉తʹܕࢦఆ͞ΕΔϩʔΧϧม
varɺܕ͋Γ·͢ʂ ໌ࣔతʹมͷܕΛॻ͔ͳ͍͚ͩʂ
// ໌ࣔతʹมͷܕΛॻ͍͍ͯΔ string name = "RyotaMurohoshi"; // =ͷӈล͕จࣈྻϦςϥϧ͔ͩΒstringܕ var title
= "ʮvarېࢭʯېࢭ";
varɺ͔͚ͯ͘ૉఢΜʂ // ΞϗΈ͍ͨʹ͍ܕ໊(ۃ)Λ2ճॻ͘ʂʁ Dictionary<HogeFuga, List<PiyoPiyoPiyo>> dictionary = new Dictionary<HogeFuga, List<PiyoPiyoPiyo>>();
// 1ճॻ͚͍͍ΑͶ var dictionary = new Dictionary<HogeFuga, List<PiyoPiyoPiyo>>(); Θ͟Θ͟ಉ͜͡ͱɺ2ճॻ͘ඞཁͳ͍ΑͶ
έʔε1·ͱΊ varʹܕ͕͋Δɺ໌ࣔతʹͳͬͯͳ͍͚ͩͰɻ ʮvarɺܕ͕ͳͯ͘ΩϞ͍͔Βېࢭͳʂʯͬͯ ݴΘΕͨ߹ɺ૬खvarΛצҧ͍͍ͯ͠Δ͔Βڭ͑ͯ͋͛Α͏ʂ
͖ͭͮ·ͯ͠...
έʔε2 ʮvarɺԿͷܕ͔͔Γʹ͍͔͘Βېࢭͳʂʯ ͬͯݴΘΕΔ
έʔε2ͷݪҼ varͷཚ༻ɻదʹvarΛ͍ͬͯͳ͍ͨΊɻ
(Զ͕ࢥ͏)#varͷྑ͘ͳ͍ར༻ྫ ʮͳΜͩΑɺ͜ͷϝιουͷฦΓͷܕʯͬͯͳΔʂ ɹ var result = GetResults();
varͷཚ༻orz
varΛͬͯܕ͕Θ͔Δ࣌ʹɺ varΛ͓͏ʂ
(Զ͕ࢥ͏)#varͷྑ͍ར༻ྫ // =ͷӈล͕Ϧςϥϧ var level = 27; var name =
"Ryota"; // =ͷӈล͕ίϯετϥΫλ or ϑΝΫτϦϝιου var playerData = new PlayerData(level, name); // =ͷӈล͕δΣωϦοΫϝιουͰܕҾ͕ฦΓܕͳ // ϝδϟʔͳϝιου(࣍ͷUnityͰྑ͘͏ͭ) var player = FindObjectOfType<Player>();
ʮΘ͟Θ͟ೋճॻ͔ͳͯ͘ӈล͔Βܕ͕Θ͔Δ͡ΌΜʯ ͱ͍͏߹varͰεοΩϦɻ
έʔε2·ͱΊ ʮvarɺԿͷܕ͔͔Γʹ͍͔͘Βېࢭͳʂʯͬͯ ͔֬ʹཚ༻͢ΔͱಡΈͮΒ͘ͳΔ͜ͱ͋Δɻ ಡΈ͘͢ͳΔ໘Ͱ͏ϧʔϧΛަব͠·͠ΐ͏ʂ
͖ͭͮ·ͯ͠...
έʔε3 ʮvarɺList<string>͕IList<string>ʹ ͳͬͯ͘Εͳ͍͔Βېࢭͳʯ ͬͯݴΘΕͨ
έʔε3ͷݪҼ JavaͰͷܦݧ͕ཧ༝ʢ͔ʁʣ ͜ͷύλʔϯ͕Ұ൪հ
varͷӈล͕List<string>ܕ͔ͩΒɺlistͷܕList<string>ʹɻ ɹ var list = new List<string>();
ࠓ͔ΒνϣοτJavaͷ
JavaͷίʔυͰ͢ // Լهͷॻ͖ํྑ͘ͳ͍ ArrayList<String> list = new ArrayList<String>(); // Լهͷॻ͖ํΛ͖͢
List<String> list = new ArrayList<String>(); // μΠϠϞϯυԋࢉࢠͰ͔͚͘Δ List<String> list = new ArrayList<>();
JavaͰμΠϠϞϯυԋࢉࢠΛ͔͍ͭɺهड़Λলུͭͭ͠ ʮϩʔΧϧมʯΛநతͳܕͰѻ͏͜ͱ͕Ͱ͖Δ
͜Εʹ׳Εͨਓ͜͏ࢥ͏߹͕͋ΔΈ͍ͨ ʮvarɺList<string>͕IList<string>ʹ ͳͬͯ͘Εͳ͍͔Βېࢭͳʯ
JavaɺμΠϠϞϯυԋࢉࢠͰهड़Λলུͭͭ͠ListΠϯλʔϑΣʔεܕͷมͰѻ͑Δ // Java List<String> list = new ArrayList<>(); C#ͷvarͷ߹ɺIList<string>ΠϯλʔϑΣʔεʹͳΒͳ͍ɻList<string>ΫϥεʹͳΔɻ //
C# var list = new List<string>();
͔֬ʹϝιουͷҾฦΓͷܕΛ దʹநతͳܕͰѻ͏ͷେ // ྑ͘ͳ͍ྫ(Java) public ArrayList<string> loadList(){ /*தུ*/ } //
վળྫ(Java) public List<string> loadList(){ /*தུ*/ }
͚ΕͲʮvarɺList<string>ΫϥεͷΦϒδΣΫτ͕ IList<string>ΠϯλʔϑΣʔεͷมʹͳΒͳ͍͔Βېࢭʯ ؒҧ͍ͬͯΔͱࢥ͏
var͕͑Δͷ ϩʔΧϧม͚ͩʂ
ϩʔΧϧมΛநܕͰѻ͏ͷͦΜͳʹେࣄʁ ઈରඞཁʁ
ϩʔΧϧมͳΒείʔϓด͍ͯͯ͡ɺ ͔͔ͨͩߦɺͯ͘2,30ߦ
varͰ͔͚͘Δ͜ͱͱɺ ͘ดͨ͡είʔϓͰϩʔΧϧมΛநతͳܕͰѻ͏͜ͱ Ͳ͕ͬͪେࣄͩΖ͏ʁ
varͰ͔͚͘Δํ͕ ͍͍ΑͶʂ
͔ͨ͠͠Β ʮJavaͰ͜͏͔ͩΒɺC#Ͱ͜͏͡Όͳ͖Όμϝʯ ػցతʹஅͯ͠Δ͔͠Εͳ͍orz
ʲಓʳʮvarɺList<string>͕IList<string>ʹͳͬͯ͘Εͳ͍͔Βېࢭͳʯ͍ͬͯ͏ਓͦ͏ʲภݟʳ ྻIList<T>࣮͍ͯ͠ΔͷΒͳͦ͏ɻ IReadOnlyList<T>ͱ͔͍͍͑ͷʹΒͳͦ͏ɻ
έʔε3·ͱΊ ʮvarɺList<string>͕IList<string>ʹͳͬͯ͘Εͳ͍͔Βېࢭͳʯ ͱݴΘΕͨΒɺϩʔΧϧมͰநతͳܕͰѻ͏ϝϦοτͱ ͘هड़Ͱ͖Δ͜ͱͷϝϦοτɺͲͪΒ͕େࣄ͔͠߹͓͏ɻ ͦͯ͠উͯʂࠓॻ͍ͯΜͷJava͡Όͳͯ͘C#ͩʂ
࠷ޙʹ • ࠓ͍ɺKotlinSwi*Ͱvar!(ͱ͔valͱ͔let) • varɺ͓͏ͥ • varɺదʹਖ਼͓͘͠͏ͥʂཚ༻μϝͳʂ • ʮvarېࢭʯېࢭͳʂʂʂ
ʮvarېࢭʯېࢭ @RyotaMurohoshi 2016/02/20()(Hokuriku(ComCamp(2016(powered(by(MVPs
ิ
ͦͷ4 ʮvar͏ͱΠϯλʔϑΣʔεܕͷมʹͳΒͳ͍͔Β ໌ࣔతͳ࣮͍ͯ͠Δϝιουݺͳ͘ͳΔ͡ΌΜʯ ͬͯݴΘΕͨΒʁ
ͦͦ͞ɺΫϥε͕Θ͔͍ͬͯΔͷʹ ΠϯλʔϑΣʔεͷ໌ࣔత࣮͍ͯ͠Δϝιου ݺͿඞཁ͋Δͷʁ