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
57
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.2k
Zeitwerk integration in Rails 6.0
murajun1978
0
110
Efficient development with GraphQL
murajun1978
0
290
Effective Debugging Apps in VS Code
murajun1978
1
880
tebukuro
murajun1978
0
110
Shinosaka.rb #17 Hands on
murajun1978
0
46
New Features in Rails 4.2
murajun1978
0
910
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
130
FactoryGirl LT
murajun1978
1
67
Other Decks in Programming
See All in Programming
Drawing Heighway’s Dragon- Recursive Function Rewrite- From Imperative Style in Pascal 64 To Functional Style in Scala 3
philipschwarz
PRO
0
150
Rubyと自由とAIと
yotii23
6
1.9k
仕様変更に耐えるための"今の"DRY原則を考える
mkmk884
9
3.3k
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
8
1.5k
未経験でSRE、はじめました! 組織を支える役割と軌跡
curekoshimizu
1
200
ソフトウェアエンジニアの成長
masuda220
PRO
12
2.2k
iOSでQRコード生成奮闘記
ktcryomm
2
120
kintone開発を効率化するためにチームで試した施策とその結果を大放出!
oguemon
0
330
Honoとフロントエンドの 型安全性について
yodaka
7
1.5k
PRレビューのお供にDanger
stoticdev
1
240
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
7
4.2k
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
290
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.4k
Building Adaptive Systems
keathley
40
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Statistics for Hackers
jakevdp
797
220k
4 Signs Your Business is Dying
shpigford
183
22k
Become a Pro
speakerdeck
PRO
26
5.2k
Designing Experiences People Love
moore
140
23k
Side Projects
sachag
452
42k
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 :)