Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
950
How to Enjoy the Murajun’s Style
murajun1978
0
75
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.4k
Zeitwerk integration in Rails 6.0
murajun1978
0
120
Efficient development with GraphQL
murajun1978
0
310
Effective Debugging Apps in VS Code
murajun1978
1
940
tebukuro
murajun1978
0
130
Shinosaka.rb #17 Hands on
murajun1978
0
62
New Features in Rails 4.2
murajun1978
0
940
Other Decks in Programming
See All in Programming
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
850
Navigating Dependency Injection with Metro
l2hyunwoo
1
120
WebRTC、 綺麗に見るか滑らかに見るか
sublimer
1
190
マスタデータ問題、マイクロサービスでどう解くか
kts
0
110
これならできる!個人開発のすゝめ
tinykitten
PRO
0
120
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
260
TUIライブラリつくってみた / i-just-make-TUI-library
kazto
1
400
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.8k
Go コードベースの構成と AI コンテキスト定義
andpad
0
130
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
150
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
140
sbt 2
xuwei_k
0
300
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
83
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
45
WCS-LA-2024
lcolladotor
0
380
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Highjacked: Video Game Concept Design
rkendrick25
PRO
0
240
SEO for Brand Visibility & Recognition
aleyda
0
4.1k
Tell your own story through comics
letsgokoyo
0
740
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
60
Become a Pro
speakerdeck
PRO
31
5.7k
Designing Powerful Visuals for Engaging Learning
tmiket
0
180
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 :)