Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
930
How to Enjoy the Murajun’s Style
murajun1978
0
72
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
130
Shinosaka.rb #17 Hands on
murajun1978
0
60
New Features in Rails 4.2
murajun1978
0
930
Other Decks in Programming
See All in Programming
Microservices Platforms: When Team Topologies Meets Microservices Patterns
cer
PRO
1
840
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
170
全員アーキテクトで挑む、 巨大で高密度なドメインの紐解き方
agatan
8
17k
Microservices rules: What good looks like
cer
PRO
0
360
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
8
3.9k
関数の挙動書き換える
takatofukui
4
760
ローターアクトEクラブ アメリカンナイト:川端 柚菜 氏(Japan O.K. ローターアクトEクラブ 会長):2720 Japan O.K. ロータリーEクラブ2025年12月1日卓話
2720japanoke
0
320
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
3
680
乱雑なコードの整理から学ぶ設計の初歩
masuda220
PRO
32
15k
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
290
分散DBって何者なんだ... Spannerから学ぶRDBとの違い
iwashi623
0
160
しっかり学ぶ java.lang.*
nagise
1
470
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.8k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
690
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
The Language of Interfaces
destraynor
162
25k
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 :)