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
55
Rubyとblock
murajun1978
February 19, 2014
Tweet
Share
More Decks by murajun1978
See All by murajun1978
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.1k
Zeitwerk integration in Rails 6.0
murajun1978
0
100
Efficient development with GraphQL
murajun1978
0
280
Effective Debugging Apps in VS Code
murajun1978
1
870
tebukuro
murajun1978
0
110
Shinosaka.rb #17 Hands on
murajun1978
0
43
New Features in Rails 4.2
murajun1978
0
900
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
120
FactoryGirl LT
murajun1978
1
66
Other Decks in Programming
See All in Programming
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
410
命名をリントする
chiroruxx
1
390
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
370
From Translations to Multi Dimension Entities
alexanderschranz
2
130
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
230
Featured
See All Featured
Six Lessons from altMBA
skipperchong
27
3.5k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Typedesign – Prime Four
hannesfritz
40
2.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
A designer walks into a library…
pauljervisheath
204
24k
Practical Orchestrator
shlominoach
186
10k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Side Projects
sachag
452
42k
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 :)