Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Ruby 2.1 Overview
Jesse Wolgamott
January 15, 2014
Technology
0
510
Ruby 2.1 Overview
(For HoustonRB)
Jesse Wolgamott
January 15, 2014
Tweet
Share
More Decks by Jesse Wolgamott
See All by Jesse Wolgamott
React vs React-Native
jwo
0
50
What is an API
jwo
0
98
DIY Rails Authentication
jwo
0
160
ActionCable - For Not Another Chat App
jwo
3
920
SlackBot.rb - Create You a Slack Bot
jwo
1
830
react-rails: an isomorphic match made in heaven
jwo
0
830
Docker - next big thing
jwo
0
490
Rails 4: Appetizers
jwo
1
540
The Long Ball: Upgrading Rails from 1.2 -> 4.0
jwo
2
170
Other Decks in Technology
See All in Technology
Step-by-Step MLOps and Microsoft Products
shisyu_gaku
2
610
DevRel組織についての考察
taijihagino
PRO
0
150
ぼくらが選んだ次のMySQL 8.0 / MySQL80 Which We Choose
line_developers
PRO
7
3.3k
ニコニコ生放送におけるWebフロントエンドBFFサーバーのKubernetes移行事例の紹介
himenon
3
630
Life Hacker with LINE Bot and GitHub API
line_developers_tw
PRO
0
5.6k
品質特性のすすめ
honamin09
0
180
Kubernetes撤退、 その後のはてなの取り組み / kubernetes meetup tokyo number 22
hayajo
4
3.2k
ReverseETLでユーザーに価値を届ける基盤を実現した話
hakky
0
360
やってみたLT会 Fleet Managerのススメ
yukiiiiikuma
PRO
0
410
サイバー攻撃を想定したクラウドネイティブセキュリティガイドラインとCNAPP及びSecurity Observabilityの未来
syoshie
2
1.5k
cobra は便利になっている
nwiizo
0
150
開発環境のセキュリティおよびCI/CDパイプラインのセキュア化
rung
PRO
12
5.2k
Featured
See All Featured
Building Adaptive Systems
keathley
25
1.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
15
3.9k
A better future with KSS
kneath
226
16k
How New CSS Is Changing Everything About Graphic Design on the Web
jensimmons
213
11k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
6k
The Illustrated Children's Guide to Kubernetes
chrisshort
18
40k
The Art of Programming - Codeland 2020
erikaheidi
32
11k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
316
19k
Infographics Made Easy
chrislema
233
17k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
6
580
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
39
13k
Become a Pro
speakerdeck
PRO
3
910
Transcript
@jwo Ruby 2.1
@jwo `def` returns a method
@jwo module Foo! def public_method! end! ! def some_other_method! end!
! private :some_other_method! ! private! def a_private_method! end! end! ! Foo.private_instance_methods! => [:some_other_method, :a_private_method]
@jwo module Foo! def public_method! end! ! private def some_other_method!
end! ! private def a_private_method! end! end! ! Foo.private_instance_methods! => [:some_other_method, :a_private_method]
@jwo Refinements Launched and the world did not end.
@jwo module Permalinker! refine String do! def permalinkify! downcase.split.join("-")! end!
end! end
@jwo class Post! using Permalinker! ! def initialize(title)! @title =
title! end! ! def permalink! @title.permalinkify! end! end
@jwo "Refinements are not globally scoped".permalinkify! ! ! ! NoMethodError:
undefined method `permalinkify' for "Refinements are not globally scoped":String
@jwo Restricted Keyword Args
@jwo def order_tacos(type: 5, how_many: 'queso')! puts "Ordering #{how_many} #{type}"!
end! ! order_tacos type: "fajita_queso", how_many: 5 in Ruby 2.0, you HAD to specify a default for type and how_many
@jwo def order_tacos(type:, how_many:)! puts "Ordering #{how_many} #{type}"! end! !
order_tacos type: "fajita_queso", how_many: 5! order_tacos type: “fajita_queso"! ! => ArgumentError: missing keyword: how_many NO LONGER
@jwo Restricted Generational Garbage Collector (RGENGC)
@jwo ummm wat
@jwo Ruby 1.8: Mark and Sweep http://tmm1.net/ruby21-rgengc/
@jwo Ruby 1.9.3 “Lazy Sweep” http://tmm1.net/ruby21-rgengc/
@jwo Ruby 2.0 bitmaps for copy-on-write safety http://tmm1.net/ruby21-rgengc/
@jwo Ruby 2.1: OldGen and minor marking http://tmm1.net/ruby21-rgengc/
@jwo Some Graphs!
@jwo Some Little Stuff
@jwo 27r # => Rational(27/1)! 1/2r # => Rational(1/2)! 12+33i
# => Complex(12,33) Decimal Literal Syntax
@jwo 3.times{puts'blah'.object_id}! # => 70287241728160! # => 70287241728080! # =>
70287241728020! ! 3.times{puts'blah'f.object_id}! # => 70287241709760 ! # => 70287241709760! # => 70287241709760 Frozen String Literal (Same)
@jwo $ stackprof data/stackprof-cpu-4120-1384979644.dump --text --limit 4 ================================== Mode: cpu(1000)
Samples: 9145 (1.25% miss rate) GC: 448 (4.90%) ================================== TOTAL (pct) SAMPLES (pct) FRAME 236 (2.6%) 231 (2.5%) String#blank? 546 (6.0%) 216 (2.4%) ActiveRecord::ConnectionAdapters::Mysql2Adapter#select 212 (2.3%) 199 (2.2%) Mysql2::Client#query_with_timing ! $ stackprof data/stackprof-cpu-4120-1384979644.dump --method 'String#blank?' String#blank? (lib/active_support/core_ext/object/blank.rb:80) samples: 231 self (2.5%) / 236 total (2.6%) callers: 112 ( 47.5%) Object#present? code: | 80 | def blank? 187 (2.0%) / 187 (2.0%) | 81 | self !~ /[^[:space:]]/ Profiling Tools (rb_profile_frames)
@jwo Install today!