Download - O que tem de novo no Ruby 2.0?
![Page 1: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/1.jpg)
O que tem de novo no
Ruby 2?Fabio Akita
@akitaonrailscodeminer42.com
![Page 2: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/2.jpg)
![Page 3: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/3.jpg)
![Page 4: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/4.jpg)
Ruby 0.95 Dez 1995
Ruby 1.8 Ago 2003
Rails 0.8 Dez 2005
Ruby 1.9 Dez 2007
![Page 5: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/5.jpg)
Ruby 0.95 Dez 1995
Ruby 1.8 Ago 2003
Rails 0.8 Dez 2005
Ruby 1.9 Dez 2007
![Page 6: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/6.jpg)
Ruby 0.95 Dez 1995
Ruby 1.8 Ago 2003
Rails 0.8 Dez 2005
Ruby 1.9 Dez 2007
![Page 7: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/7.jpg)
Ruby 0.95 Dez 1995
Ruby 1.8 Ago 2003
Rails 0.8 Dez 2005
Ruby 1.9 Dez 2007
![Page 8: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/8.jpg)
Ruby 2.024 de Fevereiro de 2013
![Page 9: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/9.jpg)
Compatível com 1.9
![Page 10: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/10.jpg)
Literal Symbol List
![Page 11: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/11.jpg)
> %q[hello world]=> "hello world"
> %i[hello world]=> [:hello, :world]
![Page 12: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/12.jpg)
Keyword Arguments
![Page 13: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/13.jpg)
def foo(options = {}) param1 = options[:param1] param2 = options[:param2] return [param1, param2]end
> foo param1: "Hello", param2: "World"=> ["Hello", "World"]
![Page 14: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/14.jpg)
def foo(param1: nil, param2: nil) return [param1, param2]end
> foo param1: "Hello", param2: "World"=> ["Hello", "World"]
![Page 15: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/15.jpg)
Module Prepend
![Page 16: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/16.jpg)
> [1,2,3].to_s=> "[1, 2, 3]"
![Page 17: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/17.jpg)
module Foo def self.included(base) base.class_eval do alias_method :original_to_s, :to_s def to_s original_to_s + ", Foo" end end endend
class Array include Fooend
![Page 18: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/18.jpg)
> [1,2,3].to_s=> "[1, 2, 3], Foo"
> Array.ancestors=> [Array, Foo, Enumerable, Object, Kernel, BasicObject]
![Page 19: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/19.jpg)
module Foo def to_s super + ", Foo" endend
class Array prepend Fooend
![Page 20: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/20.jpg)
> [1,2,3].to_s=> "[1, 2, 3], Foo"
> Array.ancestors=> [Foo, Array, Enumerable, Object, Kernel, BasicObject]
![Page 21: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/21.jpg)
Lazy Enumerators
![Page 22: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/22.jpg)
> a = (0..3).map { |i| i }=> [0, 1, 2, 3]
![Page 23: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/23.jpg)
> a = (0..3).lazy.map { |i| i }=> #<Enumerator::Lazy: #<Enumerator::Lazy: 0..3>:map>
> a.next=> 0> a.next=> 1> a.next=> 2> a.next=> 3
![Page 24: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/24.jpg)
> a = (0..Float::INFINITY).lazy.map { |i| i }=> #<Enumerator::Lazy: #<Enumerator::Lazy: 0..Infinity>:map>
> a.next=> 0> a.next=> 1> a.next=> 2> a.next=> 3
![Page 25: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/25.jpg)
Re!nements
![Page 26: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/26.jpg)
module Foo def hello "Hello, #{to_s}" endend
class Array include Fooend
> [1,2,3].hello=> "Hello, [1, 2, 3]"
![Page 27: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/27.jpg)
module Foo refine Array do def hello "Hello, #{to_s}" end endend
using Foo
> [1,2,3].hello=> "Hello, [1, 2, 3]"
![Page 28: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/28.jpg)
module Foo refine Array do def hello "Hello, #{to_s}" end endend
using Foo
> [1,2,3].hello=> "Hello, [1, 2, 3]"
def bah [1,2,3].helloend
> bah.helloNoMethodError: undefined method `hello' for "Hello, [1, 2, 3]":String
![Page 30: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/30.jpg)
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
![Page 31: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/31.jpg)
![Page 32: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/32.jpg)
![Page 33: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/33.jpg)
![Page 34: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/34.jpg)
![Page 36: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/36.jpg)
![Page 37: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/37.jpg)
![Page 38: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/38.jpg)
![Page 39: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/39.jpg)
![Page 40: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/40.jpg)
Browser
Linux
NGINX
Worker
![Page 41: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/41.jpg)
Browser
Linux
NGINX
Worker
![Page 42: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/42.jpg)
Browser
Linux
Ruby
NGINX
Worker
![Page 43: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/43.jpg)
Browser
Linux
Rails
Ruby
NGINX
Worker
![Page 44: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/44.jpg)
Browser
Linux
Rails
Ruby
NGINX
Worker
![Page 45: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/45.jpg)
Browser Browser Browser Browser
Linux
Rails
Ruby Ruby Ruby Ruby
NGINX
Rails Rails Rails
Worker Worker Worker Worker
![Page 46: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/46.jpg)
Browser Browser Browser Browser
Linux
Rails
Ruby Ruby Ruby Ruby
NGINX
Rails Rails Rails
Worker Worker Worker Worker
![Page 47: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/47.jpg)
M&SMark & Sweep GC
![Page 48: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/48.jpg)
struct RBasic { VALUE flags; VALUE klass;};
RString
klass
flags
![Page 49: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/49.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
![Page 50: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/50.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
fork()
![Page 51: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/51.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
fork()
![Page 52: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/52.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
GC.start()
RString
klass
flags
RString
klass
flags
RString
klass
flags
![Page 53: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/53.jpg)
OOBWOut of Band Work
![Page 54: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/54.jpg)
![Page 55: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/55.jpg)
![Page 56: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/56.jpg)
LazyLazy Sweep GC - Ruby 1.9.3
![Page 57: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/57.jpg)
“CoW”Copy on Write
![Page 58: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/58.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
![Page 59: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/59.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
![Page 60: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/60.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
![Page 61: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/61.jpg)
RString
klass
flags
RString
klass
flags
RString
klass
flags
![Page 62: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/62.jpg)
![Page 63: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/63.jpg)
fork()
![Page 64: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/64.jpg)
![Page 65: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/65.jpg)
![Page 66: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/66.jpg)
![Page 67: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/67.jpg)
![Page 68: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/68.jpg)
GC.start
![Page 69: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/69.jpg)
![Page 70: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/70.jpg)
![Page 71: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/71.jpg)
![Page 72: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/72.jpg)
![Page 73: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/73.jpg)
BitmapBitmap Marking GC - Ruby 2.0
![Page 74: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/74.jpg)
![Page 75: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/75.jpg)
![Page 76: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/76.jpg)
9 00001001
8 00001000
7 00000111
![Page 77: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/77.jpg)
9 00001001
8 00001000
7 00000111
![Page 78: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/78.jpg)
9 00001001
8 00001000
7 00000111
![Page 79: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/79.jpg)
![Page 80: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/80.jpg)
00000001 2^0 1 User
00000010 2^1 2 Moderator
00000100 2^2 4 Administrator
![Page 81: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/81.jpg)
00000001 2^0 1 User
00000010 2^1 2 Moderator
00000100 2^2 4 Administrator
![Page 82: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/82.jpg)
00000001 2^0 1 User
00000010 2^1 2 Moderator
00000100 2^2 4 Administrator
![Page 83: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/83.jpg)
0 0 0 0 0 0 0 01 1 1
![Page 84: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/84.jpg)
0 0 0 0 0 0 0 01 1 1
fork()
![Page 85: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/85.jpg)
fork()
![Page 86: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/86.jpg)
fork()
![Page 87: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/87.jpg)
Browser Browser Browser Browser
Linux
Rails
Ruby Ruby Ruby Ruby
NGINX
Rails Rails Rails
Worker Worker Worker Worker
![Page 88: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/88.jpg)
BrowserBrowser
Linux
Rails
Ruby
NGINX
Worker
Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby
Rails Rails Rails Rails Rails Rails Rails Rails Rails
WorkerWorkerWorkerWorkerWorkerWorkerWorkerWorkerWorker
BrowserBrowserBrowserBrowserBrowserBrowserBrowserBrowser
![Page 89: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/89.jpg)
BrowserBrowser
Linux
Rails
Ruby
NGINX
Worker
Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby
Rails Rails Rails Rails Rails Rails Rails Rails Rails
WorkerWorkerWorkerWorkerWorkerWorkerWorkerWorkerWorker
BrowserBrowserBrowserBrowserBrowserBrowserBrowserBrowser
![Page 90: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/90.jpg)
Rails 3.2.12+
Rails 4.0
![Page 91: O que tem de novo no Ruby 2.0?](https://reader033.vdocuments.pub/reader033/viewer/2022052618/554f4b15b4c905423f8b4ceb/html5/thumbnails/91.jpg)
Thanks!@akitaonrails