On 12/3/2010 9:27 AM, David E. wrote:
> So I have an object of class (user defined) Dave() and Dave2()
> 
> This may seem totally assuming, but I have a string that I get.
> 
> It will either be "Dave" or "Dave2".
> 
> Is there a way to
> 
> if string=="Dave"
>   (Dave)string.theMethod()
> else
>   (Dave2)string.theMethod()
> end
> 
> I know, again, I am taking a lot for granted, but in Python I was able
> to do this sort of thing... And of course in Java...

Ruby is not statically typed, so there is no such thing as casting.
Just assume that string.theMethod() returns an appropriate object for
the rest of the logic to consume.  As long as the returned object
responds to the appropriate methods, there will be no problems with types.

If that doesn't help, can you describe your goal in a broader sense?

-Jeremy