[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

What's difference?

Kyung won Cheon

8/18/2008 6:29:00 AM

--- test1.rb ---

b = 1
puts a if a = b

# NameError: undefined local variable or method `a' for main:Object


--- test2.rb ---

a = 1 if false
puts defined?(a)

# local-variable


###############
# Help Me^^
###############
--
Posted via http://www.ruby-....

24 Answers

Mikael Høilund

8/18/2008 7:06:00 AM

0


On Aug 18, 2008, at 8:29, Kyung won Cheon wrote:

> --- test1.rb ---
>
> b =3D 1
> puts a if a =3D b
>
> # NameError: undefined local variable or method `a' for main:Object
>


Parser peculiarity. You can't use a local variable defined for the =20
first time in the clause of an inline-if for that statement. Define a =20=

before it reaches that line, or use this instead:

if a =3D b then puts a end

--=20
# Mikael H=F8ilund
def method_missing(m, a=3D0) a +
m.to_s[/[a-z]+/].size * 2; end
p What is the meaning of life?


psy

8/18/2008 8:03:00 AM

0

Hier from Programming Ruby book. Its not exactly for this case, but i think it gets close :

----
When Ruby sees a name such as ``a'' in an expression, it needs to determine if it is a local variable reference or a call to a method with no parameters. To decide which is the case, Ruby uses a
heuristic. As Ruby reads a source file, it keeps track of symbols that have been assigned to. It assumes that these symbols are variables. When it subsequently comes across a symbol that might be
either a variable or a method call, it checks to see if it has seen a prior assignment to that symbol. If so, it treats the symbol as a variable; otherwise it treats it as a method call.
----


There is also this example down below :

----
Note that the assignment does not have to be executed---Ruby just has to have seen it. This program does not raise an error.

a = 1 if false; a
----

Greets

On Mon, 18 Aug 2008 15:29:04 +0900
Kyung won Cheon <kdream95@gmerce.co.kr> wrote:

> --- test1.rb ---
>
> b = 1
> puts a if a = b
>
> # NameError: undefined local variable or method `a' for main:Object
>
>
> --- test2.rb ---
>
> a = 1 if false
> puts defined?(a)
>
> # local-variable
>
>
> ###############
> # Help Me^^
> ###############

duke

8/10/2012 11:56:00 AM

0

On 09 Aug 2012 17:19:50 GMT, Bert <bert@iphouse.com> wrote:

>In news:5rr981.a1o.19.1@news.alt.net J <jdyoung1@ymail.com> wrote:
>
>> But the harm it would do is to the institution of marriage itself and
>> to its chief purpose which is to commit men and women to one another
>> and to their children.
>
>So you say.
>
>From where I stand, it seems like you folk are most upset by someone
>hijacking the word "marriage," which, for some reason, you think you
>own, and which has magical meaning to you.

God directed man to leave his mother and father and become one with his wife.

That's adam and eve and not adam and steve.

>Would it make you happy if the state simply got out of the "marriage"
>business and recognized only the contract of "civil union?"

That's all it is anyway. It's impossible to satisfy the definition of marriage
for them.

>You religious folks who insist on being "married" could then get
>yourself to the practitioner of your choice and have him say the words
>over you.

The dukester, American - American
********************************************
A vote for obama is a vote for the end of
democracy in America as we know it. Let the
rolling thunder guide your decision at the
ballot box to put an end to Imperial Obama.
May God bless America.
********************************************

duke

8/10/2012 11:56:00 AM

0

On Thu, 9 Aug 2012 17:47:21 +0000 (UTC), gazelle@shell.xmission.com (Kenny
McCormack) wrote:

>In article <XnsA0AA7D6EE4F1EVeebleFetzer@216.250.188.141>,
>Bert <bert@iphouse.com> wrote:
>>In news:5rr981.a1o.19.1@news.alt.net J <jdyoung1@ymail.com> wrote:
>>
>>> But the harm it would do is to the institution of marriage itself and
>>> to its chief purpose which is to commit men and women to one another
>>> and to their children.
>>
>>So you say.
>>
>>From where I stand, it seems like you folk are most upset by someone
>>hijacking the word "marriage," which, for some reason, you think you
>>own, and which has magical meaning to you.
>>
>>Would it make you happy if the state simply got out of the "marriage"
>>business and recognized only the contract of "civil union?"
>>
>>You religious folks who insist on being "married" could then get
>>yourself to the practitioner of your choice and have him say the words
>>over you.
>>
>>--
>>bert@iphouse.com St. Paul, MN
>
>As I've noted so many times in the past, the core problem is that if you
>believe the mumbo-jumbo, then there really *IS* a problem.

Yes, there is. It's called moral decadence.

God knows (pun
>intended) what could happen if those homos start getting hitched. Floods,
>famine, high unemployment, low stock prices, credit default swaps going bad,
>Republicans getting elected. The list of calamities He might inflict upon
>us is endless...

The dukester, American - American
********************************************
A vote for obama is a vote for the end of
democracy in America as we know it. Let the
rolling thunder guide your decision at the
ballot box to put an end to Imperial Obama.
May God bless America.
********************************************

Bert Hyman

8/10/2012 5:01:00 PM

0

In news:nit928pf7skqm9s60t3vgiquar0i0kuphk@4ax.com duke
<duckgumbo32@cox.net> wrote:

> God directed man to leave his mother and father and become one with
> his wife.
>
> That's adam and eve and not adam and steve.

Do you follow all the other practices prescribed in your bible?

Do you NOT do anything that's NOT prescribed in your bible?

Both seem extremely unlikely.

--
bert@iphouse.com St. Paul, MN

J

8/10/2012 5:05:00 PM

0

On 8/10/2012 10:00 AM, Bert wrote:
> In news:nit928pf7skqm9s60t3vgiquar0i0kuphk@4ax.com duke
> <duckgumbo32@cox.net> wrote:
>
>> God directed man to leave his mother and father and become one with
>> his wife.
>>
>> That's adam and eve and not adam and steve.
>
> Do you follow all the other practices prescribed in your bible?
>
> Do you NOT do anything that's NOT prescribed in your bible?
>
> Both seem extremely unlikely.
>


Nobody's perfect but I'll bet Duke is a real man, which means he prefers
women.





--
J Young
jdyoung1@ymail.com

http://www.americande...

Virgil

8/10/2012 9:46:00 PM

0

In article <nit928pf7skqm9s60t3vgiquar0i0kuphk@4ax.com>,
duke <duckgumbo32@cox.net> wrote:

> >From where I stand, it seems like you folk are most upset by someone
> >hijacking the word "marriage," which, for some reason, you think you
> >own, and which has magical meaning to you.
>
> God directed man to leave his mother and father and become one with his wife.

What god wold that be?

I know of no reasons to suppose any gods exist.


***************************************

Obama is on the common people's side.
Romney is on the wealthy people's side.
Whose side will you be on?

***************************************
--


Virgil

8/10/2012 9:48:00 PM

0

In article <0mt928d1thf0tvic4dgcfjsg3ub6baacs8@4ax.com>,
duke <duckgumbo32@cox.net> wrote:

> >As I've noted so many times in the past, the core problem is that if you
> >believe the mumbo-jumbo, then there really *IS* a problem.
>
> Yes, there is. It's called moral decadence.

If you insist that belief in your mumbo-jumbo is moral decadence, I will
not gainsay you.
--


duke

8/11/2012 12:10:00 PM

0

On 10 Aug 2012 17:00:43 GMT, Bert <bert@iphouse.com> wrote:

>In news:nit928pf7skqm9s60t3vgiquar0i0kuphk@4ax.com duke
><duckgumbo32@cox.net> wrote:
>
>> God directed man to leave his mother and father and become one with
>> his wife.

>> That's adam and eve and not adam and steve.
>Do you follow all the other practices prescribed in your bible?

For the intellectual, the bible takes the pagan to the Jew to the Christian. I
am a Christian, the no-covenant to the old covenant to the new covenant.

>Do you NOT do anything that's NOT prescribed in your bible?
>Both seem extremely unlikely.

Do you understand the above?

The dukester, American - American
********************************************
A vote for obama is a vote for the end of
democracy in America as we know it. Let the
rolling thunder guide your decision at the
ballot box to put an end to Imperial Obama.
May God bless America.
********************************************

duke

8/11/2012 12:10:00 PM

0

On Fri, 10 Aug 2012 10:05:21 -0700, J <jdyoung1@ymail.com> wrote:

>On 8/10/2012 10:00 AM, Bert wrote:
>> In news:nit928pf7skqm9s60t3vgiquar0i0kuphk@4ax.com duke
>> <duckgumbo32@cox.net> wrote:
>>
>>> God directed man to leave his mother and father and become one with
>>> his wife.
>>>
>>> That's adam and eve and not adam and steve.
>>
>> Do you follow all the other practices prescribed in your bible?
>>
>> Do you NOT do anything that's NOT prescribed in your bible?
>>
>> Both seem extremely unlikely.

>Nobody's perfect but I'll bet Duke is a real man, which means he prefers
>women.

YEAH!!

The dukester, American - American
********************************************
A vote for obama is a vote for the end of
democracy in America as we know it. Let the
rolling thunder guide your decision at the
ballot box to put an end to Imperial Obama.
May God bless America.
********************************************