N
Nick Green
More or less all my functions look something like
def foo bar baz quux
if not bar.is_a? String or
not baz.is_a? FunkyDinosaur or
not quux.respond_to? "getEatenByFunkyDinosaur"
#complain about errors w/ raise or app specific complain function
end
# do some stuff
end
There has got to be a better way to go about this parameter checking
business, but googling is not working (bad search terms maybe). Is
there?
And I don't really mean other ways of writing the same logic, i.e.
3 statements that look like:
complain "baz is no dinosaur!" unless baz.is_a? FunkyDinosaur
does not seem a whole lot better to me than the above example
def foo bar baz quux
if not bar.is_a? String or
not baz.is_a? FunkyDinosaur or
not quux.respond_to? "getEatenByFunkyDinosaur"
#complain about errors w/ raise or app specific complain function
end
# do some stuff
end
There has got to be a better way to go about this parameter checking
business, but googling is not working (bad search terms maybe). Is
there?
And I don't really mean other ways of writing the same logic, i.e.
3 statements that look like:
complain "baz is no dinosaur!" unless baz.is_a? FunkyDinosaur
does not seem a whole lot better to me than the above example