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
ちょっとしたRubyの話
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
t0yohei
November 11, 2018
Technology
530
1
Share
ちょっとしたRubyの話
t0yohei
November 11, 2018
More Decks by t0yohei
See All by t0yohei
Vue の Input における State は親で持つべきか子で持つべきか
t0yohei
0
86
Vue.js を使って Grid System を実装した話
t0yohei
2
7.7k
負債が溜まったレガシーフロントエンド画面を Vue.js でリプレイスした話
t0yohei
0
2.2k
プログラミング入門に失敗した話
t0yohei
0
220
【ITエンジニアが怪我で労災!?】 仕事中に足の小指が骨折したら起きること
t0yohei
0
450
Protocol Buffers で Web APIのスキーマ駆動開発がしたい
t0yohei
0
230
Ruby と JavaScript の違い( Function 編)
t0yohei
1
350
副業のノウハウ
t0yohei
0
210
自作キーボード入門してみた
t0yohei
0
190
Other Decks in Technology
See All in Technology
個人AIからチームAIへ:開発における品質と生産性の再設計
moongift
PRO
0
340
自称宇宙最速で不合格となったAIP-C01にリベンジを果たすべくAIで問題集アプリを作ってみた。
yama3133
0
260
「嘘をつくテスト」の失敗例から学ぶ 良いテストコード #frontend_phpcon_do
asumikam
0
110
速さだけじゃない! VoidZero ツールが移行先に選ばれる理由
mizdra
PRO
6
720
エンジニアは生成AIと どのように向き合うべきか? ことばの意味という観点から
verypluming
3
310
ルールやカスタム機能、どう使う?理想の出力を引き出すために今知りたいIBM Bob 5つの機能
muehara
0
170
AI時代の私の技術インプットとアウトプット術
tonkotsuboy_com
15
8.1k
組織の中で自分を経営する技術
shoota
0
230
GoとSIMDとWasmの今。
askua
2
420
TROCCOで始めるクラウドコストを民主化するためのFinOps
tk3fftk
2
520
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
570
Datadog 認定試験の概要と対策
uechishingo
0
210
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
410
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Color Theory Basics | Prateek | Gurzu
gurzu
0
320
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
830
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Test your architecture with Archunit
thirion
1
2.3k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
The Limits of Empathy - UXLibs8
cassininazir
1
340
The Art of Programming - Codeland 2020
erikaheidi
57
14k
How to build a perfect <img>
jonoalderson
1
5.5k
Transcript
ちょっとしたRubyの話 2018/11/11 @t0yohei
Rubyにそこまで詳しくない人 or Ruby初めてまもない人向けです
Rubyとは • 1993年にMatzが開発 • OSS言語 • Ruby on Railsとは切っても切れない縁 •
Rubyの実装はC言語でされている • そのため、MatzはRubyエンジニアではなくCエンジニア
私がRuby好きな理由 • Rubyと同い年で謎の親近感(1993年生まれ) • プログラミングを好きにしてくれた言語 • スラスラ書ける • 開発者コミュニティーが心地よい
Rubyの言語的特徴 • オブジェクト指向言語 • 動的型付けスクリプト言語 • etc...
Rubyの面白い所
(ほぼ)全てがオブジェクト • Class → Classクラスのオブジェクト • method → Objectクラスのオブジェクト
Class クラス
Method クラス
動的型付けの特性を生かしたダックタイピング • 引数に渡したobjectが、そのメソッドを持っていたら実行できる • ex) def count_object(object) p object.count end
object = [1, 2, 3] count_object(object) #結果 => 3 object = “123” count_object(object) #結果 => 3 object = { 1 => “1”, 2 => 2 , 3 => “3” } count_object(object) #結果 => 3 String Array Hash count_objectというメソッドを定義 引数は一つ(型はなんでもいい)
動的型付けの特性を生かしたダックタイピング 変数名: string、型: String 変数名: array、型: Array メソッド名: one_count、引数: 可変長引数
変数名: object、型: countメソッドを持っている何か 実行されて結果が帰ってくる
好きなメソッド (Array#inject) 配列の合計値の計算 injectを使わない場合
好きなメソッド (Array#inject) 配列の合計値の計算 injectを使った場合
小話 Q. 次の配列arrayAから配列arrayBの要素を取り除くには?? arrayA = [1, 2, 3] arrayB =
[1, 2] 変数名: arrayA、型: Array 変数名: arrayB、型: Array
小話 Q. 次の配列arrayAから配列arrayBの要素を取り除くには?? arrayA = [1, 2, 3] arrayB =
[1, 2] → 配列arrayAから配列arrayBから、型: Array、要素: 1 の配列を作りたい ex) arrayC = [1] https://twitter.com/bendhalpern/status/1060965181759635456 変数名: arrayA、型: Array 変数名: arrayB、型: Array
Ruby楽しいよ!