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
370
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
630
Odin Validationはいいぞ!
ryotamurohoshi
2
860
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.3k
Unityでも、新しいC#
ryotamurohoshi
0
1.2k
Riderはいいぞ!
ryotamurohoshi
1
3.2k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.2k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
36k
ImportedLinqのススメ
ryotamurohoshi
0
1.3k
Other Decks in Technology
See All in Technology
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
170
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
ドメイン名の終活について - JPAAWG 7th -
mikit
33
20k
SSMRunbook作成の勘所_20241120
koichiotomo
2
150
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
380
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
470
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
9
970
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
830
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Facilitating Awesome Meetings
lara
50
6.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Visualization
eitanlees
145
15k
We Have a Design System, Now What?
morganepeng
50
7.2k
What's in a price? How to price your products and services
michaelherold
243
12k
Why Our Code Smells
bkeepers
PRO
334
57k
Side Projects
sachag
452
42k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
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͏ͱΠϯλʔϑΣʔεܕͷมʹͳΒͳ͍͔Β ໌ࣔతͳ࣮͍ͯ͠Δϝιουݺͳ͘ͳΔ͡ΌΜʯ ͬͯݴΘΕͨΒʁ
ͦͦ͞ɺΫϥε͕Θ͔͍ͬͯΔͷʹ ΠϯλʔϑΣʔεͷ໌ࣔత࣮͍ͯ͠Δϝιου ݺͿඞཁ͋Δͷʁ