Nick4
(Nick)
26 March 2003 22:10
1
Hi,
Why does the following give me a problem:
def calc(inValue)
if(inValue =~ /^([-+]?[0-9]+)([CF])$/)
InputValue = $1
InputType = $2
end
end
calc(‘22C’)
Error reported is:
RegExp.rbw:24: dynamic constant assignment
InputType = $2
Thanks,
Nick.
Because in Ruby, constants start with an uppercase letter.
Use a lowercase letter as start of the variable name instead.
-Martin
···
On Thu, Mar 27, 2003 at 07:10:04AM +0900, Nick wrote:
Hi,
Why does the following give me a problem:
def calc(inValue)
if(inValue =~ /^([-+]?[0-9]+)([CF])$/)
InputValue = $1
InputType = $2
end
end
calc(‘22C’)
Error reported is:
RegExp.rbw:24: dynamic constant assignment
InputType = $2
Nick4
(Nick)
27 March 2003 21:14
4
ah…doh…thanks for that!
dblack@superlink.net wrote in message
news:Pine.LNX.4.44.0303261720580.7205-100000@candle.superlink.net …
···
Hi –
On Thu, 27 Mar 2003, Nick wrote:
Hi,
Why does the following give me a problem:
def calc(inValue)
if(inValue =~ /^([-+]?[0-9]+)([CF])$/)
InputValue = $1
InputType = $2
end
end
calc(‘22C’)
Error reported is:
RegExp.rbw:24: dynamic constant assignment
InputType = $2
It gives that error message because you’ve dynamically assigned to a
constant Names beginning with uppercase letters are constants.
Try input_value and input_type.
David
–
David Alan Black
home: dblack@superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav