Skip to content

Instantly share code, notes, and snippets.

@tight
Created February 7, 2012 10:07

Revisions

  1. tight revised this gist Feb 7, 2012. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,15 @@
    i = "foo"
    for i in 1..5 do
    puts i
    j = "bar"
    end
    i
    # => 5

    i # => 5
    j # => "bar"

    i = "foo"
    (1..5).each do |i|
    puts i
    k = "bar"
    end
    i
    # "foo"
    i # => "foo"
    k # => NameError
  2. tight created this gist Feb 7, 2012.
    14 changes: 14 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    i = "foo"
    for i in 1..5 do
    puts i
    end
    i
    # => 5


    i = "foo"
    (1..5).each do |i|
    puts i
    end
    i
    # "foo"