> A very common situation is that the users don't know all the possible
> return types of 'some_third_party_function()'. If the users don't know
> all the return types, he/she can not make sure the return type of
> function(x) {...} be always the same. How do you deal with this case?

It's not that common.  It's pretty bad practice to return different
types from a function depending on the input parameters.  In many
languages this isn't even possible.

The solution is to write a function that takes the output from the
first function, inspects it, and coerces all possibilities to the same
type.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to