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
60
Rubyとblock
murajun1978
February 19, 2014
Tweet
Share
More Decks by murajun1978
See All by murajun1978
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
1k
How to Enjoy the Murajun’s Style
murajun1978
0
80
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
320
Effective Debugging Apps in VS Code
murajun1978
1
950
tebukuro
murajun1978
0
130
Shinosaka.rb #17 Hands on
murajun1978
0
64
New Features in Rails 4.2
murajun1978
0
940
Other Decks in Programming
See All in Programming
Patterns of Patterns
denyspoltorak
0
640
dchart: charts from deck markup
ajstarks
3
960
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
860
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
160
CSC307 Lecture 05
javiergs
PRO
0
470
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
500
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
670
Grafana:建立系統全知視角的捷徑
blueswen
0
290
CSC307 Lecture 01
javiergs
PRO
0
670
Cap'n Webについて
yusukebe
0
170
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
340
生成AI時代を勝ち抜くエンジニア組織マネジメント
coconala_engineer
0
40k
Featured
See All Featured
Fireside Chat
paigeccino
41
3.8k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
560
Ethics towards AI in product and experience design
skipperchong
1
170
Mobile First: as difficult as doing things right
swwweet
225
10k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
250
A Soul's Torment
seathinner
5
2.1k
How STYLIGHT went responsive
nonsquared
100
6k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
140
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Designing for humans not robots
tammielis
254
26k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
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 :)