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
570
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
52
What is an API
jwo
0
100
DIY Rails Authentication
jwo
0
160
ActionCable - For Not Another Chat App
jwo
3
1k
SlackBot.rb - Create You a Slack Bot
jwo
1
910
react-rails: an isomorphic match made in heaven
jwo
0
880
Docker - next big thing
jwo
0
550
Rails 4: Appetizers
jwo
1
590
The Long Ball: Upgrading Rails from 1.2 -> 4.0
jwo
2
180
Other Decks in Technology
See All in Technology
UEでPLATEAU触ってみた
41h0_shiho
0
250
5分でわかるファストドクターテクノロジーズ
fast_doctor
0
110
USB PD で迎える AC アダプター大統一時代
puhitaku
2
2k
データ分析基盤の要件分析の話(202201_JEDAI)
yabooun
0
400
2年で10→70人へ! スタートアップの 情報セキュリティ課題と施策
miekobayashi
1
720
JAWS-UG 横浜 #54 資料
takakuni
0
220
OpenShift.Run2023_create-aro-with-terraform
ishiitaiki20fixer
1
370
開発者と協働できるメトリクスダッシュボードを作ろう!/SRE Lounge 2023
lmi
3
670
re:Inventで発表があったIoT事例の紹介と考察
kizawa2020
0
200
230125 古いタブレットの活用 かーでぃさん
comucal
PRO
0
17k
クックパッドがRubyKaigiに20名以上の社員で参加するわけ
midorikawa
0
580
Dockerに疲れた人のためのLXDではじめるシステムコンテナ入門
devops_vtj
0
140
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
29
8k
How To Stay Up To Date on Web Technology
chriscoyier
779
250k
Become a Pro
speakerdeck
PRO
6
3.2k
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
Intergalactic Javascript Robots from Outer Space
tanoku
261
26k
Designing for humans not robots
tammielis
245
24k
Testing 201, or: Great Expectations
jmmastey
25
5.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
317
22k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
120
29k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
182
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
346
17k
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!