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
1
510
ちょっとしたRubyの話
t0yohei
November 11, 2018
Tweet
Share
More Decks by t0yohei
See All by t0yohei
Vue の Input における State は親で持つべきか子で持つべきか
t0yohei
0
66
Vue.js を使って Grid System を実装した話
t0yohei
2
7.5k
負債が溜まったレガシーフロントエンド画面を Vue.js でリプレイスした話
t0yohei
0
2.1k
プログラミング入門に失敗した話
t0yohei
0
200
【ITエンジニアが怪我で労災!?】 仕事中に足の小指が骨折したら起きること
t0yohei
0
440
Protocol Buffers で Web APIのスキーマ駆動開発がしたい
t0yohei
0
210
Ruby と JavaScript の違い( Function 編)
t0yohei
1
340
副業のノウハウ
t0yohei
0
200
自作キーボード入門してみた
t0yohei
0
170
Other Decks in Technology
See All in Technology
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
2
380
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
370
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
5.6k
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
130
What happened to RubyGems and what can we learn?
mikemcquaid
0
310
Claude_CodeでSEOを最適化する_AI_Ops_Community_Vol.2__マーケティングx_AIはここまで進化した.pdf
riku_423
2
600
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
250
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
360
AzureでのIaC - Bicep? Terraform? それ早く言ってよ会議
torumakabe
1
590
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
180
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
700
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
The SEO Collaboration Effect
kristinabergwall1
0
350
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
150
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
120
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
180
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
270
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.7k
From π to Pie charts
rasagy
0
120
HDC tutorial
michielstock
1
390
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
170
Visualization
eitanlees
150
17k
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楽しいよ!