• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby 2.0 at the Ruby drink-up of Sophia, February 2013
 

Ruby 2.0 at the Ruby drink-up of Sophia, February 2013

on

  • 668 views

Presented at the Ruby Drink-up of Sophia Antipolis on the 5th of February 2013 by Philippe Antras (@_philant_).

Presented at the Ruby Drink-up of Sophia Antipolis on the 5th of February 2013 by Philippe Antras (@_philant_).

Statistics

Views

Total Views
668
Views on SlideShare
663
Embed Views
5

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 5

https://twitter.com 4
https://web.tweetdeck.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby 2.0 at the Ruby drink-up of Sophia, February 2013 Ruby 2.0 at the Ruby drink-up of Sophia, February 2013 Presentation Transcript

    • Ruby 2.0 bootstrap for discussionPhilippe Antras@_philant_ Riviera.rb
    • The version number goes up to 2.0 butthe changes are rather small. Smallerthan the ones we made in 1.9. Matz
    • refinementsexperimentallocalized monkey patchingrefinements are file scopeonly top-level "using" is availableno module scope refinementno refinement inheritance
    • refinement example module MyModule refine String do def price? self.include? "$" end end end using MyModule p "$13".price?
    • keyword arguments(named parameters)mandatory argumentsdefault valuesparameter validationlist (with splat operator)readability
    • def ruby_drinkup(topics, # mandatory where: "the Green King", date: "02/05/13", time: "18:30", announced: false, booked: false) ...endruby_drinkup(["rubinius", "ruby 2.0"])ruby_drinkup(["???"], date: "03/05/13")ruby_drinkup(["rubinius", "ruby 2.0"], reserved: true, announced: false)
    • lazy enumeratorsbuild an internal block and iterates only onceenumerate infinite or very large datasetsiterate on a file without loading it all map flat_map select reject grep zip take take_while drop drop_while cycle
    • next drinkup dates ?def first_tuesday?(date) date.tuesday? && date.day <= 7enddrinkups = Date.today..Float::INFINITY .lazy .select { |day| first_tuesday?(day) } .take_while { |day| day.year == 2013 } .forceputs drinkups
    • lines = File.foreach(BIG_FILE) .lazy .select { |line| line.match /ERR/ } .take(10) .to_a
    • rails
    • takeaway2.0.0-rc2 delayed yesterdayrefinements, safer, cleaner, but experimentalkeyword argumentslazy enumeratorscompatible with Rails 3.2
    • so, whats new ?module#prepend declarations of the module overwrite those in the classArray#bsearch { |x| block } elements have to be ordered or nil is returnedEnumerator#size, Range#size#to_h convert Struct and OpenStruct to Hash%i and %I %i{one two three} => [:one, :two, :three]Dtrace support
    • what changed ?onigmo (new regex engine) positive and negative lookbehind, named captures, backreferences improvedgarbage collector bitmap marking, smaller memory footprintpsych (use libyaml)default encoding now is UTF-8respond_to? returns false for protected methodsiconv has been removed use String#encode instead
    • referencesfor more details:https://bugs.ruby-lang.org/projects/ruby-trunk/roadmap#2.0.0https://github.com/ruby/ruby/blob/v2_0_0_rc1/NEWShttps://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpechttp://blog.headius.com/2012/11/refining-ruby.htmlhttp://ruby-doc.org/core-2.0/Enumerator/Lazy.htmlhttp://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/51301http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0http://www.ruby-forum.com/topic/4409612http://www.ruby-forum.com/topic/4408480http://globaldev.co.uk/2012/11/ruby-2-0-0-preview-features/https://speakerdeck.com/a_matsuda/ruby-2-dot-0-on-rails
    • wanna give it a try ?thank you