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
t0yohei
November 11, 2018
Technology
540
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ちょっとしたRubyの話
t0yohei
November 11, 2018
More Decks by t0yohei
See All by t0yohei
Vue の Input における State は親で持つべきか子で持つべきか
t0yohei
0
98
Vue.js を使って Grid System を実装した話
t0yohei
2
7.9k
負債が溜まったレガシーフロントエンド画面を Vue.js でリプレイスした話
t0yohei
0
2.3k
プログラミング入門に失敗した話
t0yohei
0
240
【ITエンジニアが怪我で労災!?】 仕事中に足の小指が骨折したら起きること
t0yohei
0
460
Protocol Buffers で Web APIのスキーマ駆動開発がしたい
t0yohei
0
230
Ruby と JavaScript の違い( Function 編)
t0yohei
1
370
副業のノウハウ
t0yohei
0
220
自作キーボード入門してみた
t0yohei
0
200
Other Decks in Technology
See All in Technology
Guerilla InnerSource in enterprises, during the AI hype
onenashev
PRO
0
140
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
180
AI駆動開発を組織で促すために
lycorptech_jp
PRO
7
9.2k
Does an AI Watermark Survive Translation?
machinetranslation
0
520
『自分で判断できるか』を基準に、プロダクトのハンズオン研修でAI利用の線を引いてみた / Where We Drew the Line on AI in Hands-on Training
honyanya
1
850
AI活用の現在地、 ちゃんと見えてますか?/XPfest-2026
visional_engineering_and_design
0
100
Continuous Delivery! It is not what you think it is
tdpauw
0
180
IDperturb: Enhancing Variation in Synthetic Face Generation via Angular Perturbation
sansantech
PRO
0
110
[RSJ26] AnoleVLA: Lightweight Vision-Language-Action Model with Deep State Space Models for Mobile Manipulation
keio_smilab
PRO
0
120
[RSJ26] Building a VLA Model Based on Self-Distilled Classification
keio_smilab
PRO
0
170
生成AI時代の クレデンシャルとパーミッション設計
nrinetcom
PRO
3
1.4k
Nav2、Nav3 ... はたまた自作?〜 作って理解する Nav3 の設計意図 〜 / Nav2, Nav3 ... or Build Your Own? — Understanding Nav3's design intent by building it from scratch
yanzm
0
180
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.9k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Fireside Chat
paigeccino
42
4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
570
Accessibility Awareness
sabderemane
1
190
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
640
A designer walks into a library…
pauljervisheath
211
24k
Writing Fast Ruby
sferik
630
63k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
From π to Pie charts
rasagy
0
350
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楽しいよ!