R
Robert Klemme
Hi all,
conversion of method parameters seems to be a quite common scenario,
example:
def silly_example(str, count)
str = str.to_str
count = count.to_int
s = ""
count.times { s << str }
s
end
Usually these conversions are documented as requirements for method
parameters. We could make them a bit more explicit without changing much
especially not the power of Duck Typing. Here's an idea:
def silly_example(str.to_str, count.to_int)
# str and count are converted like in the example above
s = ""
count.times { s << str }
s
end
Basically this is just a way to save typing. Error reporting will be the
same. RDoc could evaluate this info and generate comments for this
automagically.
Of course, any method could be invoked like this, maybe even with
parameters. I haven't thouroughly thought about implications of that fact
yet.
Thoughs?
robert
conversion of method parameters seems to be a quite common scenario,
example:
def silly_example(str, count)
str = str.to_str
count = count.to_int
s = ""
count.times { s << str }
s
end
Usually these conversions are documented as requirements for method
parameters. We could make them a bit more explicit without changing much
especially not the power of Duck Typing. Here's an idea:
def silly_example(str.to_str, count.to_int)
# str and count are converted like in the example above
s = ""
count.times { s << str }
s
end
Basically this is just a way to save typing. Error reporting will be the
same. RDoc could evaluate this info and generate comments for this
automagically.
Of course, any method could be invoked like this, maybe even with
parameters. I haven't thouroughly thought about implications of that fact
yet.
Thoughs?
robert