[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Variable scoping

Sam Roberts

3/20/2005 4:04:00 PM

Quoting xrfang@hotmail.com, on Sun, Mar 20, 2005 at 02:44:56PM +0900:
> Hi All,
>
> Recently I found a slightly annoying behavior in Ruby -- local variable
> scoping: Example of code:
>
> Javascript version:
>
> var aNumber = 3
> function doSomething()
> {
> var anotherNumber = aNumber *2
> }
>
> Translate to Ruby:
>
> aNumber = 3
> def doSomething
> anotherNumber = aNumber * 2
> end

aNumber goes somewhere in the meta-class of Object, I think.

Here's a useful idiom:

@aNumber=3
==>3
def doSomething; @aNumber*2; end
==>nil
doSomething
==>6

You could redo your example appending "@" before evaling the variable, I suspect.

Sam



32 Answers

Velvet Jones

8/29/2009 11:40:00 PM

0

"Sweetbac" <sweetbacz@scbglobal.net> wrote in message
news:h7c7nq$o6u$1@news.eternal-september.org...
>
> "Velvet Jones" <Velvet@Jones.org> wrote in message
> news:4a999562$0$31261$607ed4bc@cv.net...
>
>> One song. Not eggzactly a reunion.
>
> Jeez...I dint say it was a world tour!
> I figured I would make a music related post.
> Maybe folks would like to hear about this.
> They's Tuna/Airplane fans on this chatgroup.
> Then...Then you go and harsh our mellow.
> You proud of yasself there, Velvet Hard-On?

<shrug> Uh yeah...lemme restore 'yer mellow with an cyb SNYC on tap. <snerk>

It's not like Donny & Marie are back together. Or Janet & Michael. Or Ren &
Stimpy.



--
VJ
-Who among us has not dreamed of faraway places and intertwined lovers?

Ray O'Hara

8/30/2009 12:39:00 AM

0


"Velvet Jones" <Velvet@Jones.org> wrote in message
news:4a99bc5c$0$31282$607ed4bc@cv.net...
> "Sweetbac" <sweetbacz@scbglobal.net> wrote in message
> news:h7c7nq$o6u$1@news.eternal-september.org...
>>
>> "Velvet Jones" <Velvet@Jones.org> wrote in message
>> news:4a999562$0$31261$607ed4bc@cv.net...
>>
>>> One song. Not eggzactly a reunion.
>>
>> Jeez...I dint say it was a world tour!
>> I figured I would make a music related post.
>> Maybe folks would like to hear about this.
>> They's Tuna/Airplane fans on this chatgroup.
>> Then...Then you go and harsh our mellow.
>> You proud of yasself there, Velvet Hard-On?
>
> <shrug> Uh yeah...lemme restore 'yer mellow with an cyb SNYC on tap.
> <snerk>
>
> It's not like Donny & Marie are back together. Or Janet & Michael. Or Ren
> & Stimpy.
>

philistine


Sherry in Vermont

8/30/2009 2:43:00 AM

0

On 2009-08-29 19:40:12 -0400, "Velvet Jones" <Velvet@Jones.org> said:

> "Sweetbac" <sweetbacz@scbglobal.net> wrote in message
> news:h7c7nq$o6u$1@news.eternal-september.org...
>>
>> "Velvet Jones" <Velvet@Jones.org> wrote in message
>> news:4a999562$0$31261$607ed4bc@cv.net...
>>
>>> One song. Not eggzactly a reunion.
>>
>> Jeez...I dint say it was a world tour!
>> I figured I would make a music related post.
>> Maybe folks would like to hear about this.
>> They's Tuna/Airplane fans on this chatgroup.
>> Then...Then you go and harsh our mellow.
>> You proud of yasself there, Velvet Hard-On?
>
> <shrug> Uh yeah...lemme restore 'yer mellow with an cyb SNYC on tap. <snerk>
>
> It's not like Donny & Marie are back together. Or Janet & Michael. Or
> Ren & Stimpy.

No, but I've hear that Donny is going to be on Dancing With the
Stars... Marie came in 3rd when she was on it in the 5th season. I've
never seen this show, but I will watch it to see Donny... I wonder how
he aged - he used to be quite the cute lil puppy-lover.

Sherry in Vermont

farfrm_me

8/30/2009 2:45:00 AM

0


>
>No, but I've hear that Donny is going to be on Dancing With the
>Stars... Marie came in 3rd when she was on it in the 5th season. I've
>never seen this show, but I will watch it to see Donny... I wonder how
>he aged - he used to be quite the cute lil puppy-lover.
>
>Sherry in Vermont
Ahhhh....now we got our Mellow back.... :-)

Ray O'Hara

8/30/2009 2:50:00 AM

0


"Sherry in Vermont" <sherry13@together.net> wrote in message
news:2009082922424877923-sherry13@togethernet...
> No, but I've hear that Donny is going to be on Dancing With the Stars...
> Marie came in 3rd when she was on it in the 5th season. I've never seen
> this show, but I will watch it to see Donny... I wonder how he aged - he
> used to be quite the cute lil puppy-lover.
>
> Sherry in Vermont
>

and maybe he's looking for another wife.
the more "sisterwives" the less work for any of them.


Sherry in Vermont

8/30/2009 3:04:00 AM

0

On 2009-08-29 22:49:48 -0400, "Ray O'Hara" <raymond-ohara@hotmail.com> said:

>
> "Sherry in Vermont" <sherry13@together.net> wrote in message
> news:2009082922424877923-sherry13@togethernet...
>> No, but I've hear that Donny is going to be on Dancing With the Stars...
>> Marie came in 3rd when she was on it in the 5th season. I've never seen
>> this show, but I will watch it to see Donny... I wonder how he aged - he
>> used to be quite the cute lil puppy-lover.
>>
>> Sherry in Vermont
>>
>
> and maybe he's looking for another wife.
> the more "sisterwives" the less work for any of them.

Hell no! I wanted to marry him when I was 13... much older and wiser
now, happy with Andre 19 years now. :) But he was my first "crush"...
and I still like purple.

Sherry in Vermont

Sweetbac

8/30/2009 3:43:00 AM

0


"Sherry in Vermouth" <sherry13@together.net> wrote in message
news:2009082923034737709-sherry13@togethernet...

> happy with Andre 19 years now. :)

> Sherry in Vermouth

Shirley....I been meaning to ask...what exactly attracted
you to Andre?....was it the bowl cut?



mr.rapidan

8/30/2009 6:13:00 AM

0

> No, but I've hear that Donny is going to be on Dancing With the
> Stars...

He best not look sideways at the Iceman. That's all.

Sherry in Vermont

8/30/2009 3:00:00 PM

0

On 2009-08-30 02:12:39 -0400, "mr.rapidan" <jminpa@gmail.com> said:

>> No, but I've hear that Donny is going to be on Dancing With the
>> Stars...
>
> He best not look sideways at the Iceman. That's all.

Err... who?

Sherry in Vermont

Velvet Jones

8/30/2009 4:06:00 PM

0

"Ray O'Hara" <raymond-ohara@hotmail.com> wrote in message
news:h7cpce$ku7$1@news.eternal-september.org...
>
> "Sherry in Vermont" <sherry13@together.net> wrote in message
> news:2009082922424877923-sherry13@togethernet...
>> No, but I've hear that Donny is going to be on Dancing With the Stars...
>> Marie came in 3rd when she was on it in the 5th season. I've never seen
>> this show, but I will watch it to see Donny... I wonder how he aged - he
>> used to be quite the cute lil puppy-lover.
>>
>> Sherry in Vermont
>>
>
> and maybe he's looking for another wife.
> the more "sisterwives" the less work for any of them.


Yee haw. Love my Big Love.