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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
murajun1978
February 19, 2014
Programming
0
61
Rubyとblock
murajun1978
February 19, 2014
Tweet
Share
More Decks by murajun1978
See All by murajun1978
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
1.1k
How to Enjoy the Murajun’s Style
murajun1978
0
88
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
960
tebukuro
murajun1978
0
130
Shinosaka.rb #17 Hands on
murajun1978
0
66
New Features in Rails 4.2
murajun1978
0
950
Other Decks in Programming
See All in Programming
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
240
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
350
あなたはユーザーではない #PdENight
kajitack
4
300
CSC307 Lecture 14
javiergs
PRO
0
450
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
210
浮動小数の比較について
kishikawakatsumi
0
380
Windows on Ryzen and I
seosoft
0
120
AIに任せる範囲を安全に広げるためにやっていること
fukucheee
0
110
Railsの気持ちを考えながらコントローラとビューを整頓する/tidying-rails-controllers-and-views-as-rails-think
moro
4
370
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
150
Codex の「自走力」を高める
yorifuji
0
710
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
3.4k
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Producing Creativity
orderedlist
PRO
348
40k
So, you think you're a good person
axbom
PRO
2
1.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
230
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Are puppies a ranking factor?
jonoalderson
1
3.1k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
330
Designing for Timeless Needs
cassininazir
0
150
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.8k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
84
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
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 :)