Hi -- On Sun, 28 May 2006, Daniel Schierbeck wrote: > Now, I'm sure you'll all hate this, but I just had to post it. > > What if optional "type hinting", or, more accurately, "type conversion", was > added to the method definition syntax? It sounds like you're talking about class, rather than type, or (since, as you say, to_x doesn't actually have to return an X) just a kind of convenience method-call layer. I'd rather see the methods spelled out. > def foo(str bar, i baz, sym bur) > # something > end > > would then be the same as > > def foo(arg1, arg2, arg3) > bar, baz, bur = arg1.to_str, arg2.to_i, arg3.to_sym > end > > I know it would save me a lot of typing -- plus, it's still dynamic; it > wouldn't (necessarily) require the return values of the #to_* calls to be > instances of a certain class. > > I know that some of you prefer to just call methods on the received > arguments, and not use the #to_* methods first to convert them to a certain > "type", but this proposal/idea wouldn't in any way make that more difficult > than it is today. It might make it less common, though -- that is, discourage duck typing and reinforce the concept that what really matters is what class an object is. David -- David A. Black (dblack / wobblini.net) * Ruby Power and Light, LLC (http://www.rubypowerandlight.com) > Ruby and Rails consultancy and training * Author of "Ruby for Rails" from Manning Publications! > http://www.manning.com/black