Created
November 24, 2010 16:12
-
-
Save k0001/713891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Problema: | |
| module Foo | |
| @hello = 42 | |
| class Bar | |
| # Desde acá quiero llegar a @hello. | |
| end | |
| end | |
| # Solución funcional horrible (amateur?). Hay una mejor forma? | |
| module Foo | |
| @hello = 42 | |
| def self.hello | |
| @hello | |
| end | |
| class Bar | |
| puts Foo.hello | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No quiero mantener un estado; puse
42solo a modo de ejemplo, pero en realidad estoy asignando un objeto un poco mas complejo ahí, a modo de singleton. Una instancia a la cual todas las classes dentro del moduloFoodeberían tener acceso.