Ruby 1.9 Introduction
Upcoming SlideShare
Loading in...5
×
 

Ruby 1.9 Introduction

on

  • 7,307 views

Slides from my very introductory talk on Ruby 1.9 given at SD Ruby in April 2009.

Slides from my very introductory talk on Ruby 1.9 given at SD Ruby in April 2009.

Statistics

Views

Total Views
7,307
Views on SlideShare
7,246
Embed Views
61

Actions

Likes
17
Downloads
282
Comments
1

1 Embed 61

http://www.slideshare.net 61

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

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…
  • As a management instructor I appreciate viewing the work of others. This is one of the best demonstration on planning I've viewed.
    Sharika
    http://winkhealth.com http://financewink.com
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Ruby 1.9 Introduction Ruby 1.9 Introduction Presentation Transcript

  • Ruby1.9.1
  • Ruby1.9.1 Brad Feeley
  • Ruby1.9.1 Brad Feeley I work at Digitaria
  • Ruby1.9.1 What is it?
  • 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.
  • Ruby1.9.1 Faster JRuby
  • Ruby1.9.1 Faster New virtual machine YARV
  • Ruby1.9.1 Faster Maybe another presentation? New virtual machine YARV Kernal (native) threads
  • Ruby1.9.1 Multilingualized a.k.a. m17n
  • Ruby1.9.1 Multilingualized File Level Encoding
  • Ruby1.9.1 Multilingualized File Level Encoding # encodeing: utf-8 alias π = Math::PI
  • Ruby1.9.1 Multilingualized String Level Encoding
  • Ruby1.9.1 Multilingualized String Level Encoding my_string.encode(“iso-8859-1”)
  • Ruby1.9.1 Multilingualized IO Level Encoding
  • Ruby1.9.1 Multilingualized IO Level Encoding f.open(‘file.txt’, ‘r:ascii’) data = f.read data.encoding.name # => ‘US-ASCII’
  • Ruby1.9.1 Cleaner Syntax
  • Cleaner Syntax Ruby1.9.1 String No longer Enumerable
  • 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]
  • 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 }
  • Cleaner Syntax Ruby1.9.1 String str = “test” str.clear # => “” “hellonworld”.lines # => [“hellon”, “world”] “hello”.encoding # => “UTF-8” “kitty”.start_with? “cat” # => false “kitty”.end_with? “tty” # => true
  • Cleaner Syntax Ruby1.9.1 Array
  • 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]
  • Cleaner Syntax Ruby1.9.1 Hash
  • Cleaner Syntax Ruby1.9.1 Hash New Key Value Syntax
  • Cleaner Syntax Ruby1.9.1 Hash New Key Value Syntax 1.8 render :action => ‘new’
  • Cleaner Syntax Ruby1.9.1 Hash New Key Value Syntax 1.8 render :action => ‘new’ 1.9 render action: ‘new’
  • 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 }
  • 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 }
  • Cleaner Syntax Ruby1.9.1 Proc
  • Cleaner Syntax Ruby1.9.1 Proc New Declaration Syntax 1.8 say_hi = lambda { |a| “Hello, #{a}” }
  • Cleaner Syntax Ruby1.9.1 Proc New Declaration Syntax 1.8 say_hi = lambda { |a| “Hello, #{a}” } 1.9 say_hi = ->(a){ “Hello, #{a}” }
  • Cleaner Syntax Ruby1.9.1 Proc New Declaration Syntax 1.8 a = lambda { |x, y=1| x * y } #=> ERROR
  • 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 }
  • Cleaner Syntax Ruby1.9.1 Proc New Calling Syntax say_hi = lambda { |a| “Hello, #{a}” } 1.8 say_hi.call(‘Quentin’) # => Hello, Quentin
  • 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
  • Cleaner Syntax Ruby1.9.1 Block Scope n = “Hello, World!” [1,2,3].each do |n| #do something end
  • Cleaner Syntax Ruby1.9.1 Block Scope n = “Hello, World!” [1,2,3].each do |n| #do something end 1.8 puts n # => 3
  • 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!”
  • Cleaner Syntax Ruby1.9.1 Debugging
  • Cleaner Syntax Ruby1.9.1 Debugging -w whitespace
  • Cleaner Syntax Ruby1.9.1 Debugging -w whitespace Method#owner #=> module the method belongs to Method#source_location #=> where the method is defined
  • 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
  • Ruby1.9.1 Ruby on Rails
  • Ruby1.9.1 Resources •http://www.google.com
  • Ruby1.9.1 Questions?