Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rubyとblock
Search
murajun1978
February 19, 2014
Programming
73
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rubyとblock
murajun1978
February 19, 2014
More Decks by murajun1978
See All by murajun1978
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
1.5k
How to Enjoy the Murajun’s Style
murajun1978
0
120
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.6k
Zeitwerk integration in Rails 6.0
murajun1978
0
160
Efficient development with GraphQL
murajun1978
0
340
Effective Debugging Apps in VS Code
murajun1978
1
1k
tebukuro
murajun1978
0
160
Shinosaka.rb #17 Hands on
murajun1978
0
80
New Features in Rails 4.2
murajun1978
0
990
Other Decks in Programming
See All in Programming
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.3k
AWSに止められる覚悟してますか?
morizo_1984
2
500
mrbgem 三角測量 開発
ogom
0
170
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
380
setup-vp GitLab対応の裏側
naokihaba
0
150
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
The Rails Doctrine Decade
koic
2
460
FreeBSDでZabbixを動かす
kenkino
0
350
Java 27新機能 / Java 27 new features
kishida
2
190
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
570
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
140
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
300
How to train your dragon (web standard)
notwaldorf
97
6.8k
Speed Design
sergeychernyshev
33
2.1k
How STYLIGHT went responsive
nonsquared
100
6.3k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
A better future with KSS
kneath
240
18k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
730
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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 :)