Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby 2.0

Jun Lin
November 27, 2012

Ruby 2.0

A glance of Ruby 2.0

Jun Lin

November 27, 2012
Tweet

More Decks by Jun Lin

Other Decks in Programming

Transcript

  1. • A mechanism to extend Classes and Modules locally •

    Lexically scoped • Safer and cleaner than open-class monkey patching
  2. module Foo refine String do def say "Yoho, #{self}!" end

    end end class Bar using Foo def aloha 'Bar'.say end end
  3. class A def foo 'foo' end end module B def

    foo super + 'bar' end end class C < A prepend B def foo super + 'COOL' end end
  4. [2, 4, 6, 8, 10, 12, 14, 16, 18, 20,

    22, 24, 26, 28, 30, 32, 34, 36, 38, 40]
  5. END