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?
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.
Well, it’s just an idea.
(putting on my flame-proof suit)
Daniel