Ruby - cannot modify a frozen string (TypeError)

Got

... '[] =': it is not possible to change the frozen string (TypeError)

when trying to change what I thought was a copy of ARGV [0].

The same results for each of

arg = ARGV[ 0 ] arg_cloned = ARGV[ 0 ].clone arg_to_s = ARGV[ 0 ].to_s arg[ 'x' ] = 'y' arg_cloned[ 'x' ] = 'y' arg_to_s[ 'x' ] = 'y' 
+49
ruby
Feb 05 '10 at 3:56
source share
1 answer

since google took too long to find the right answer ...

required

 arg_dup = ARGV[ 0 ].dup 
+87
Feb 05 '10 at 3:57
source share



All Articles