From: "Ara.T.Howard" Date: 2005-07-31T13:16:12+09:00 Subject: Re: [newbie] make local var visible --8323328-1705500738-1122783366=:17676 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1705500738-1122783366=:17676" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1705500738-1122783366=:17676 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 29 Jul 2005, [iso-8859-1] "Pe=F1a, Botp" wrote: > Yes. I've done what you have all suggested. Thank you. > But I was hoping for something "cleaner". Sorry. > > Can we request RCR for this? > > I like the private/public clause for methods. I hope we can provide > something like it for vars though; that is, make local vars "public" or > "private" > > like, > > #test.rb > #sample script---------------->8 > > private_var foo=09# <--declare something like this or whatever > # foo will be visible up to end of test.rb only > # as if foo now becomes @foo, or $foo, or what > > foo=3D["a","b","c"] > > def mfoo > foo.each do |f| > p f > end > end > > # go-go-go! > mfoo > #end sample script------------>8 > > > Will this break ruby design? > If yes, please forget i asked. > > Thanks and kind regards -botp maybe: harp:~ > cat a.rb require 'traits' trait 'foo' =3D> %w( a b c ) def mfoo foo.each{|f| p f} end mfoo harp:~ > ruby a.rb "a" "b" "c" or you can write this require 'traits' trait 'foo' foo 42 def mfoo foo.each{|f| p f} end mfoo which is kinda close to what you want. hth. -a --=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D --8323328-1705500738-1122783366=:17676-- --8323328-1705500738-1122783366=:17676--