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
67
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
150
Efficient development with GraphQL
murajun1978
0
340
Effective Debugging Apps in VS Code
murajun1978
1
1k
tebukuro
murajun1978
0
150
Shinosaka.rb #17 Hands on
murajun1978
0
74
New Features in Rails 4.2
murajun1978
0
970
Other Decks in Programming
See All in Programming
Cloudflare is Agents
chimame
0
180
Android CLI
fornewid
0
230
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
140
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
290
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
420
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
350
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
250
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
280
「人を評価する AI」の設計と実装
ryoyanara
0
230
FastAPI の並行処理モデルを完全に理解する
hoto17296
8
2.8k
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
560
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
120
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
220
How STYLIGHT went responsive
nonsquared
100
6.2k
The SEO identity crisis: Don't let AI make you average
varn
0
530
GitHub's CSS Performance
jonrohan
1033
470k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
800
Bash Introduction
62gerente
615
220k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
400
Accessibility Awareness
sabderemane
1
180
The World Runs on Bad Software
bkeepers
PRO
72
12k
Navigating Team Friction
lara
192
16k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
710
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
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 :)