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
60
Rubyとblock
murajun1978
February 19, 2014
Tweet
Share
More Decks by murajun1978
See All by murajun1978
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
840
How to Enjoy the Murajun’s Style
murajun1978
0
64
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
920
tebukuro
murajun1978
0
120
Shinosaka.rb #17 Hands on
murajun1978
0
55
New Features in Rails 4.2
murajun1978
0
930
Other Decks in Programming
See All in Programming
ててべんす独演会〜Flowの全てを語ります〜
tbsten
1
220
なぜGoのジェネリクスはこの形なのか? Featherweight Goが明かす設計の核心
ryotaros
7
1k
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
390
デミカツ切り抜きで面倒くさいことはPythonにやらせよう
aokswork3
0
190
プロダクト開発をAI 1stに変革する〜SaaS is dead時代で生き残るために〜 / AI 1st Product Development
kobakei
0
490
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
180
Чего вы не знали о строках в Python – Василий Рябов, PythoNN
sobolevn
0
160
Django Ninja による API 開発効率化とリプレースの実践
kashewnuts
0
930
Pull-Requestの内容を1クリックで動作確認可能にするワークフロー
natmark
2
450
CSC509 Lecture 05
javiergs
PRO
0
290
Local Peer-to-Peer APIはどのように使われていくのか?
hal_spidernight
2
450
GitHub Actions × AWS OIDC連携の仕組みと経緯を理解する
ota1022
0
240
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
850
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Build your cross-platform service in a week with App Engine
jlugia
232
18k
Unsuck your backbone
ammeep
671
58k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
19
1.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Bash Introduction
62gerente
615
210k
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 :)