Ruby 1.9 Introduction

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    9 Favorites

    Ruby 1.9 Introduction - Presentation Transcript

    1. Ruby1.9.1
    2. Ruby1.9.1 Brad Feeley
    3. Ruby1.9.1 Brad Feeley I work at Digitaria
    4. Ruby1.9.1 What is it?
    5. Ruby1.9.1 What is it? “ Ruby 1.9 is a new series of Ruby. It is modern, faster, with clearer syntax, multilingualized, a much improved version of Ruby.
    6. Ruby1.9.1 Faster JRuby
    7. Ruby1.9.1 Faster New virtual machine YARV
    8. Ruby1.9.1 Faster Maybe another presentation? New virtual machine YARV Kernal (native) threads
    9. Ruby1.9.1 Multilingualized a.k.a. m17n
    10. Ruby1.9.1 Multilingualized File Level Encoding
    11. Ruby1.9.1 Multilingualized File Level Encoding # encodeing: utf-8 alias π = Math::PI
    12. Ruby1.9.1 Multilingualized String Level Encoding
    13. Ruby1.9.1 Multilingualized String Level Encoding my_string.encode(“iso-8859-1”)
    14. Ruby1.9.1 Multilingualized IO Level Encoding
    15. Ruby1.9.1 Multilingualized IO Level Encoding f.open(‘file.txt’, ‘r:ascii’) data = f.read data.encoding.name # => ‘US-ASCII’
    16. Ruby1.9.1 Cleaner Syntax
    17. Cleaner Syntax Ruby1.9.1 String No longer Enumerable
    18. Cleaner Syntax Ruby1.9.1 String No longer Enumerable 1.8 String.ancestors => [String, Enumerable, Comparable, Object, Kernel] 1.9 String.ancestors => [String, Comparable, Object, Kernel]
    19. Cleaner Syntax Ruby1.9.1 String No longer Enumerable 1.8 my_string_var.each { |line| puts line } 1.9 my_string_var.each_line { |line| puts line }
    20. Cleaner Syntax Ruby1.9.1 String str = “test” str.clear # => “” “hello\\nworld”.lines # => [“hello\\n”, “world”] “hello”.encoding # => “UTF-8” “kitty”.start_with? “cat” # => false “kitty”.end_with? “tty” # => true
    21. Cleaner Syntax Ruby1.9.1 Array
    22. Cleaner Syntax Ruby1.9.1 Array vowels = ['a','e','i', ‘o’, ‘u’] vowels.index{|letter| letter == 'e'} # => 1 a = [1,2,3] a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]] a.combination(2).to_a #=> [[1, 2], [1, 3], [2, 3]] a.to_s # => “[1, 2, 3]” a.pop(2) #=> [2, 3]
    23. Cleaner Syntax Ruby1.9.1 Hash
    24. Cleaner Syntax Ruby1.9.1 Hash New Key Value Syntax
    25. Cleaner Syntax Ruby1.9.1 Hash New Key Value Syntax 1.8 render :action => ‘new’
    26. Cleaner Syntax Ruby1.9.1 Hash New Key Value Syntax 1.8 render :action => ‘new’ 1.9 render action: ‘new’
    27. Cleaner Syntax Ruby1.9.1 Hash Order Preservation h = {:a => 1, :b => 2, :c => 3 } h[:d] = 4 1.8 puts h.inspect => {:4 => d, :a => 1, :b => 2, :c => 3 }
    28. Cleaner Syntax Ruby1.9.1 Hash Order Preservation h = {:a => 1, :b => 2, :c => 3 } h[:d] = 4 1.8 puts h.inspect => {:4 => d, :a => 1, :b => 2, :c => 3 } 1.9 puts h.inspect => {:a => 1, :b => 2, :c => 3, :4 => d }
    29. Cleaner Syntax Ruby1.9.1 Proc
    30. Cleaner Syntax Ruby1.9.1 Proc New Declaration Syntax 1.8 say_hi = lambda { |a| “Hello, #{a}” }
    31. Cleaner Syntax Ruby1.9.1 Proc New Declaration Syntax 1.8 say_hi = lambda { |a| “Hello, #{a}” } 1.9 say_hi = ->(a){ “Hello, #{a}” }
    32. Cleaner Syntax Ruby1.9.1 Proc New Declaration Syntax 1.8 a = lambda { |x, y=1| x * y } #=> ERROR
    33. Cleaner Syntax Ruby1.9.1 Proc New Declaration Syntax 1.8 a = lambda { |x, y=1| x * y } #=> ERROR 1.9 a = ->(x, y=1){ x * y } a = ->(&x){ x.call }
    34. Cleaner Syntax Ruby1.9.1 Proc New Calling Syntax say_hi = lambda { |a| “Hello, #{a}” } 1.8 say_hi.call(‘Quentin’) # => Hello, Quentin
    35. Cleaner Syntax Ruby1.9.1 Proc New Calling Syntax say_hi = lambda { |a| “Hello, #{a}” } 1.8 say_hi.call(‘Quentin’) # => Hello, Quentin 1.9 say_hi.(‘Quentin’) # => Hello, Quentin
    36. Cleaner Syntax Ruby1.9.1 Block Scope n = “Hello, World!” [1,2,3].each do |n| #do something end
    37. Cleaner Syntax Ruby1.9.1 Block Scope n = “Hello, World!” [1,2,3].each do |n| #do something end 1.8 puts n # => 3
    38. Cleaner Syntax Ruby1.9.1 Block Scope n = “Hello, World!” [1,2,3].each do |n| #do something end 1.8 puts n # => 3 1.9 puts n # => “Hello, World!”
    39. Cleaner Syntax Ruby1.9.1 Debugging
    40. Cleaner Syntax Ruby1.9.1 Debugging -w whitespace
    41. Cleaner Syntax Ruby1.9.1 Debugging -w whitespace Method#owner #=> module the method belongs to Method#source_location #=> where the method is defined
    42. Ruby1.9.1 Installation http://gist.github.com/59130 wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.bz2 tar -xjvf ruby-1.9.1-p0.tar.bz2 cd ruby-1.9.1-p0 ./configure --prefix=/usr --program-suffix=19 --enable-shared make && make install
    43. Ruby1.9.1 Ruby on Rails
    44. Ruby1.9.1 Resources •http://www.google.com
    45. Ruby1.9.1 Questions?

    + Bradly FeeleyBradly Feeley, 6 months ago

    custom

    1567 views, 9 favs, 0 embeds more stats

    Slides from my very introductory talk on Ruby 1.9 g more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1567
      • 1567 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 9
    • Downloads 82
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories