# Make local var visible

**URL:** <https://rubytalk.org/t/make-local-var-visible/19811>\
**Category:** ruby-talk\
**Created:** [29 July 2005 12:35 UTC](https://rubytalk.org/t/make-local-var-visible/19811 "2005-07-29T12:35:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Pena\_Botp1](https://avatars.discourse-cdn.com/v4/letter/_/94ad74/32.png) [@\_Pena\_Botp1](https://rubytalk.org/u/_Pena_Botp1)\
**Post date:** [29 July 2005 12:35 UTC](https://rubytalk.org/t/make-local-var-visible/19811/1 "2005-07-29T12:35:11Z")

</div>

#You could do:

> **···**
>
> Trans [[mailto:transfire@gmail.com](mailto:transfire@gmail.com)] wrote:
> 
> #  
> # Foo=["a","b","c"]  
> #  
> # def mfoo  
> # Foo.each do |f|  
> # p f  
> # end  
> # end  
> #  
> # # go-go-go!  
> # mfoo  
> #  
> #Yet I tend to agree. Even in classes, it just seems so much more  
> #elegant:  
> #  
> # class Bar  
> #  
> # foo = ["a","b","c"] # attribute  
> #  
> # def mfoo  
> # foo.each do |f|  
> # p f  
> # end  
> # end  
> #  
> # end  
> #  
> #But the only way to do that woud be:  
> #  
> #1) Irregular attr syntax.  
> #  
> # attr foo = ["a","b","c"]  
> #  
> #2) Alternate assignment operator.  
> #  
> # foo := ["a","b","c"]  
> #  
> #3) Prefixed local vars.  
> #  
> # %local\_var = 'what have you'  
> #  
> #I myself have suggested before that  
> #  
> # foo = 10  
> #  
> #be essentially equivalent to  
> #  
> # def foo ; 10 ; end  
> #  
> #And that constants and methods share the same namespace.  
> #  
> #T.
> 
> Agree on all.  
> Thanks, Trans.
> 
> kind regards -botp
> 
> #  
> #
