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
910
How to Enjoy the Murajun’s Style
murajun1978
0
69
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
930
tebukuro
murajun1978
0
120
Shinosaka.rb #17 Hands on
murajun1978
0
58
New Features in Rails 4.2
murajun1978
0
930
Other Decks in Programming
See All in Programming
CloudflareのSandbox SDKを試してみた
syumai
0
150
AI駆動開発ライフサイクル(AI-DLC)のホワイトペーパーを解説
swxhariu5
0
930
Rails Girls Sapporo 2ndの裏側―準備の日々から見えた、私が得たもの / SAPPORO ENGINEER BASE #11
lemonade_37
2
160
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
500
2026年向け会社紹介資料
misu
0
190
Amazon Bedrock Knowledge Bases Hands-on
konny0311
0
150
チーム開発の “地ならし"
konifar
7
4.5k
Core MIDI を勉強して作曲用の電子ピアノ作ってみた!
hypebeans
0
110
Honoを技術選定したAI要件定義プラットフォームAcsimでの意思決定
codenote
0
230
Kotlin + Power-Assert 言語組み込みならではのAssertion Library採用と運用ベストプラクティス by Kazuki Matsuda/Gen-AX
kazukima
0
110
モビリティSaaSにおけるデータ利活用の発展
nealle
0
190
AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming
kishida
9
4.6k
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
Music & Morning Musume
bryan
46
6.9k
Into the Great Unknown - MozCon
thekraken
40
2.2k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Producing Creativity
orderedlist
PRO
348
40k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
The Cult of Friendly URLs
andyhume
79
6.7k
Statistics for Hackers
jakevdp
799
220k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Navigating Team Friction
lara
190
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 :)