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
1k
How to Enjoy the Murajun’s Style
murajun1978
0
83
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.5k
Zeitwerk integration in Rails 6.0
murajun1978
0
130
Efficient development with GraphQL
murajun1978
0
320
Effective Debugging Apps in VS Code
murajun1978
1
950
tebukuro
murajun1978
0
130
Shinosaka.rb #17 Hands on
murajun1978
0
64
New Features in Rails 4.2
murajun1978
0
950
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
550
CSC307 Lecture 01
javiergs
PRO
0
690
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
130
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.5k
高速開発のためのコード整理術
sutetotanuki
1
400
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
dchart: charts from deck markup
ajstarks
3
990
Package Management Learnings from Homebrew
mikemcquaid
0
220
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
230
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.1k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Documentation Writing (for coders)
carmenintech
77
5.2k
Typedesign – Prime Four
hannesfritz
42
2.9k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
180
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
330
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
AI: The stuff that nobody shows you
jnunemaker
PRO
2
250
The Spectacular Lies of Maps
axbom
PRO
1
520
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 :)