Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. ericanderson revised this gist Mar 25, 2010. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion How to use a variable declared within a module in a class.rb
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,7 @@ def stuff
    puts x
    end
    end
    end
    end

    x = Q::C.new.stuff
    # NameError: undefined local variable or method `x' for #<Q::C:0x100348c20>
  2. ericanderson renamed this gist Mar 25, 2010. 1 changed file with 0 additions and 0 deletions.
  3. @invalid-email-address Anonymous renamed this gist Mar 25, 2010. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @invalid-email-address Anonymous created this gist Mar 25, 2010.
    9 changes: 9 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    module Q
    x = 3

    class C
    def stuff
    puts x
    end
    end
    end