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
0
58
Rubyとblock
murajun1978
February 19, 2014
Tweet
Share
More Decks by murajun1978
See All by murajun1978
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.3k
Zeitwerk integration in Rails 6.0
murajun1978
0
110
Efficient development with GraphQL
murajun1978
0
300
Effective Debugging Apps in VS Code
murajun1978
1
890
tebukuro
murajun1978
0
120
Shinosaka.rb #17 Hands on
murajun1978
0
48
New Features in Rails 4.2
murajun1978
0
910
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
140
FactoryGirl LT
murajun1978
1
69
Other Decks in Programming
See All in Programming
カウシェで Four Keys の改善を試みた理由
ike002jp
1
120
Boost Your Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
770
Fiber Scheduler vs. General-Purpose Parallel Client
hayaokimura
1
290
Serving TUIs over SSH with Go
caarlos0
0
580
iOSアプリで測る!名古屋駅までの 方向と距離
ryunakayama
0
150
The Implementations of Advanced LR Parser Algorithm
junk0612
2
1.3k
ASP.NETアプリケーションのモダナイゼーションについて
tomokusaba
0
240
ComposeでのPicture in Picture
takathemax
0
130
プロフェッショナルとしての成長「問題の深掘り」が導く真のスキルアップ / issue-analysis-and-skill-up
minodriven
8
1.9k
今話題のMCPサーバーをFastAPIでサッと作ってみた
yuukis
0
110
Golangci-lint v2爆誕: 君たちはどうすべきか
logica0419
1
230
Make Parsers Compatible Using Automata Learning
makenowjust
2
6.9k
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
BBQ
matthewcrist
88
9.6k
Thoughts on Productivity
jonyablonski
69
4.6k
The World Runs on Bad Software
bkeepers
PRO
68
11k
Building an army of robots
kneath
305
45k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
119
51k
Designing Experiences People Love
moore
142
24k
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 :)