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.2k
Zeitwerk integration in Rails 6.0
murajun1978
0
100
Efficient development with GraphQL
murajun1978
0
290
Effective Debugging Apps in VS Code
murajun1978
1
880
tebukuro
murajun1978
0
110
Shinosaka.rb #17 Hands on
murajun1978
0
44
New Features in Rails 4.2
murajun1978
0
900
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
130
FactoryGirl LT
murajun1978
1
67
Other Decks in Programming
See All in Programming
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
330
チームリードになって変わったこと
isaka1022
0
200
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
120
Writing documentation can be fun with plugin system
okuramasafumi
0
120
技術を根付かせる / How to make technology take root
kubode
1
250
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1k
SwiftUI Viewの責務分離
elmetal
PRO
1
240
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
170
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
250
Amazon Q Developer Proで効率化するAPI開発入門
seike460
PRO
0
110
Honoをフロントエンドで使う 3つのやり方
yusukebe
7
3.3k
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
5
390
Featured
See All Featured
Producing Creativity
orderedlist
PRO
344
39k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Practical Orchestrator
shlominoach
186
10k
Documentation Writing (for coders)
carmenintech
67
4.6k
Docker and Python
trallard
44
3.3k
Statistics for Hackers
jakevdp
797
220k
Designing for Performance
lara
604
68k
Testing 201, or: Great Expectations
jmmastey
42
7.2k
Code Reviewing Like a Champion
maltzj
521
39k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
Navigating Team Friction
lara
183
15k
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 :)