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
58
Rubyとblock
murajun1978
February 19, 2014
Tweet
Share
More Decks by murajun1978
See All by murajun1978
How to Enjoy the Murajun’s Style
murajun1978
0
55
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.3k
Zeitwerk integration in Rails 6.0
murajun1978
0
110
Efficient development with GraphQL
murajun1978
0
310
Effective Debugging Apps in VS Code
murajun1978
1
900
tebukuro
murajun1978
0
120
Shinosaka.rb #17 Hands on
murajun1978
0
53
New Features in Rails 4.2
murajun1978
0
920
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
140
Other Decks in Programming
See All in Programming
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
130
Team operations that are not burdened by SRE
kazatohiei
1
210
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
4
950
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.9k
生成AIで日々のエラー調査を進めたい
yuyaabo
0
650
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
380
童醫院敏捷轉型的實踐經驗
cclai999
0
190
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
810
関数型まつりレポート for JuliaTokai #22
antimon2
0
150
Gleamという選択肢
comamoca
6
760
Deep Dive into ~/.claude/projects
hiragram
8
1.5k
XSLTで作るBrainfuck処理系
makki_d
0
210
Featured
See All Featured
The Language of Interfaces
destraynor
158
25k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.3k
Side Projects
sachag
455
42k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Into the Great Unknown - MozCon
thekraken
39
1.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
How to Ace a Technical Interview
jacobian
277
23k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Documentation Writing (for coders)
carmenintech
72
4.9k
Designing for Performance
lara
609
69k
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 :)