Skip to content

Instantly share code, notes, and snippets.

@rauchy
Created November 25, 2012 04:39
Show Gist options
  • Select an option

  • Save rauchy/4142419 to your computer and use it in GitHub Desktop.

Select an option

Save rauchy/4142419 to your computer and use it in GitHub Desktop.

Revisions

  1. Omer Lachish-Rauchwerger revised this gist Nov 25, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bypass_gates.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    a = 1

    Foo = Class.new do
    # a is 1 here
    # a == 1 here
    b = 2

    define_method(:bar) do
  2. Omer Lachish-Rauchwerger revised this gist Nov 25, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions scope_gates.rb
    Original file line number Diff line number Diff line change
    @@ -10,9 +10,9 @@ def bar
    end

    def baz
    # c is undefined here
    # a, b & c are undefined here
    d = 4
    end

    # c & d are undefined here
    # a, c & d are undefined here
    end
  3. Omer Lachish-Rauchwerger revised this gist Nov 25, 2012. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions bypass_gates.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    a = 1

    Foo = Class.new do
    # a is 1 here
    b = 2

    define_method(:bar) do
    # a == 1 here, b == 2 here
    c = 3
    end

    define_method(:baz) do
    # a == 1 here, b == 2 here
    # c is undefined here
    d = 4
    end

    # a == 1 here, b == 2 here
    # c & d are undefined here
    end
  4. Omer Lachish-Rauchwerger revised this gist Nov 25, 2012. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions scope_gates.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    a = 1

    class Foo
    # a is undefined here
    b = 2

    def bar
    # a & b are undefined here
    c = 3
    end

    def baz
    # c is undefined here
    d = 4
    end

    # c & d are undefined here
    end
  5. Omer Lachish-Rauchwerger created this gist Nov 25, 2012.
    9 changes: 9 additions & 0 deletions share_scope.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    class Foo
    def initialize
    @hello = "world"
    end

    def bar
    puts @hello
    end
    end