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
murajun1978
February 19, 2014
Programming
63
0
Share
Rubyとblock
murajun1978
February 19, 2014
More Decks by murajun1978
See All by murajun1978
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
1.2k
How to Enjoy the Murajun’s Style
murajun1978
0
96
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
330
Effective Debugging Apps in VS Code
murajun1978
1
970
tebukuro
murajun1978
0
140
Shinosaka.rb #17 Hands on
murajun1978
0
70
New Features in Rails 4.2
murajun1978
0
960
Other Decks in Programming
See All in Programming
Running Swift without an OS
kishikawakatsumi
0
850
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
180
GoogleCloudとterraform完全に理解した
terisuke
1
150
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
3
1k
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
620
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
400
How Swift's Type System Guides AI Agents
koher
0
300
第3木曜LT会 #28
tinykitten
PRO
0
110
GitHubCopilotCLIをはじめよう.pdf
htkym
0
240
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
110
AI-DLC Deep Dive
yuukiyo
9
4.7k
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
150
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
260
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
130
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Skip the Path - Find Your Career Trail
mkilby
1
110
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Designing Powerful Visuals for Engaging Learning
tmiket
1
350
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
440
How GitHub (no longer) Works
holman
316
150k
Six Lessons from altMBA
skipperchong
29
4.2k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
770
Bash Introduction
62gerente
615
210k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
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 :)