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
47
New Features in Rails 4.2
murajun1978
0
910
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
130
FactoryGirl LT
murajun1978
1
68
Other Decks in Programming
See All in Programming
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
300
AWS Step Functions は CDK で書こう!
konokenj
5
910
技術を改善し続ける
gumioji
0
180
複数のAWSアカウントから横断で 利用する Lambda Authorizer の作り方
tc3jp
0
130
DRFを少しずつ オニオンアーキテクチャに寄せていく DjangoCongress JP 2025
nealle
2
300
Modern Angular with Signals and Signal StoreNew Rules for Your Architecture @bastacon 2025 in Frankfurt
manfredsteyer
PRO
0
100
未経験でSRE、はじめました! 組織を支える役割と軌跡
curekoshimizu
1
210
Better Code Design in PHP
afilina
0
190
CDKを使ったPagerDuty連携インフラのテンプレート化
shibuya_shogo
0
120
楽しく向き合う例外対応
okutsu
0
740
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1.1k
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
5
1.2k
Featured
See All Featured
Facilitating Awesome Meetings
lara
53
6.3k
The Cult of Friendly URLs
andyhume
78
6.2k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Side Projects
sachag
452
42k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Into the Great Unknown - MozCon
thekraken
35
1.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Designing for humans not robots
tammielis
250
25k
Unsuck your backbone
ammeep
669
57k
Building Your Own Lightsaber
phodgson
104
6.2k
Rails Girls Zürich Keynote
gr2m
94
13k
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 :)