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とblock
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
murajun1978
February 19, 2014
Programming
0
61
Rubyとblock
murajun1978
February 19, 2014
Tweet
Share
More Decks by murajun1978
See All by murajun1978
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
1.1k
How to Enjoy the Murajun’s Style
murajun1978
0
87
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.5k
Zeitwerk integration in Rails 6.0
murajun1978
0
130
Efficient development with GraphQL
murajun1978
0
320
Effective Debugging Apps in VS Code
murajun1978
1
960
tebukuro
murajun1978
0
130
Shinosaka.rb #17 Hands on
murajun1978
0
66
New Features in Rails 4.2
murajun1978
0
950
Other Decks in Programming
See All in Programming
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
2.2k
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
170
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
3
350
ぼくの開発環境2026
yuzneri
1
290
CSC307 Lecture 08
javiergs
PRO
0
690
2026年は Rust 置き換えが流行る! / 20260220-niigata-5min-tech
girigiribauer
0
210
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
350
TipKitTips
ktcryomm
0
130
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
360
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
7
1.2k
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
400
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
540
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Believing is Seeing
oripsolob
1
68
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.3k
Utilizing Notion as your number one productivity tool
mfonobong
3
240
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
64
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Navigating Weather and Climate Data
rabernat
0
130
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
370
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.4k
Transcript
Ruby&block
block do…end {…}
yield def foo yield end foo do puts "Hello!" end
#=> Hello!
yield def foo yield if block_given? end foo do puts
"Hello!" end #=> Hello! ! foo #=>
proc def foo &proc proc.call end proc = Proc.new do
puts "Hello!" end foo &proc #=> Hello!
proc def foo name, &proc proc.call(name) end proc = Proc.new
do |name| puts “Hello, #{name}!” end foo “Ruby”, &proc #=> Hello, Ruby!
lambda def foo &lambda lambda.call end lambda = -> {puts
“Hello!”} foo &lambda #=> Hello!
proc ͱ lambda def foo block block.call 1, 2 end
foo proc { |x, y, z| p x #=> 1 p y #=> 2 p z # => nil } def foo block block.call 1, 2 end foo lambda { |x, y, z| p x p y p z } # ArgumentError
Rails model class User < ActiveRecord::Base def admin? end end
admin = [] User.all.each do |user| admin << user if user.admin? end User.select {|user| user.admin?} User.select(&:admin?)
Rails model scope class User < ActiveRecord::Base AUTHORITY_ADMIN = “admin”
scope :admin, -> { where(authority: AUTHORITY_ADMIN) } ! def admin? end end
I can have fun coding in in Ruby
Thanks :)