How to make a string upcase?

I want to change a string to upcase like below:

[email protected]

But got this error: dynamic constant assignment

Hi,

I want to change a string to upcase like below:

[email protected]

But got this error: dynamic constant assignment

Can you post the surrounding code also? Otherwise it will difficult to
help you.

Pedro

On Mon, Sep 1, 2008 at 10:07 AM, Zhao Yi [email protected] wrote:

I want to change a string to upcase like below:

[email protected]

But got this error: dynamic constant assignment

irb(main):001:0> @value = “test”
=> “test”
irb(main):002:0> [email protected]
=> “TEST”

Can you post more code? The above snippet with a test string for @value
doesn’t give any error, so it must be something else…

Jesus.

Zhao Yi wrote:

I want to change a string to upcase like below:

[email protected]

But got this error: dynamic constant assignment

If your variable’s name is uppercase then it’s a constant. This can
produce the error:

[email protected]

Don’t start local variable names with uppercase.

Sebastian H. wrote:

Zhao Yi wrote:

I want to change a string to upcase like below:

[email protected]

But got this error: dynamic constant assignment

Not for that code you didn’t.
If it was Name with a capital N and if the line was inside a method,
then
you’d get that error. And you’d get that because you’re not supposed to
assign constants from within methods (you can get around that, but most
of
the times, you shouldn’t).

HTH,
Sebastian

oh, it is upcase.

thanks.

Zhao Yi wrote:

I want to change a string to upcase like below:

[email protected]

But got this error: dynamic constant assignment

Not for that code you didn’t.
If it was Name with a capital N and if the line was inside a method,
then
you’d get that error. And you’d get that because you’re not supposed to
assign constants from within methods (you can get around that, but most
of
the times, you shouldn’t).

HTH,
Sebastian

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs