Ge Bro wrote:
> ['some_item', 'other_item'].each do |this_array|
>   ..
>   this_object = this_array.to_s.capitalize   #<== here's the problem

> the problem is, this_object becomes a string with the value of
> |this_array|.

This loop:

['some_item', 'other_item'].each do |this_array|

says to take each element in the array and stuff it in the variable 
this_array.  The array is that thing surrounded by brackets. Since each 
element of the array is a string--that's what the quotes mean--those 
strings get stuffed into the variable this_array in turn.  For example, 
the first time through the loop, the string 'some_item' will get stuffed 
into the variable this_array.

Inside the loop, you tell ruby to convert the string stored in 
this_array, which is 'some_item', into a string, but the string 
'some_item' is already a string, so  the to_s method call doesn't do 
anything.  Then you say to capitalize the string 'some_item', which 
gives you: 'Some_item', and then you assign 'Some_item to this_object.

> the problem is, this_object becomes a string with the value of
> |this_array|. How do I explain to the program that its value is not just 
> a string, but actually a name of the class

'Some_item' is the name of a class?  Where is the 'Some_item' class 
defined in your code?  For that matter, where is any class defined in 
your code?

-- 
Posted via http://www.ruby-forum.com/.