Can Coldfusion define type of array in function argument?
coldfusion
Solution
In short, as Peter has said in his comment, the basic answer is "you can't". ColdFusion doesn't have the notion of typeful arrays.
There's two ways around this. Firstly the brute-force approach of validating each array item as you need it, making sure it's the type you need. This is what Peter suggests, and generally what I'd do.
Failing that you could implement an `ActionItemCollection.cfc` which itself contains an array of `ActionItems`, and leave it to `ActionItemCollection.cfc` to only accept `ActionItem` objects, so by the time your `render()` function receives its `ActionItemCollection` argument, it "knows" each element in the collection is definitely an `ActionItem`.
That said, that's perhaps an awful lot of work when you could just get `render()` to check if the element is legit, and throw an exception if not. It's not a perfect solution, but CF is creating an imperfect situation, so fair enough.
Problem
Inside a ColdFusion component I declare a function like this: ``` string function render(required Array actions) output=false { //... } ``` So the function parameter can only accept an Array. However, I need to make sure the array contains only "ActionItem" objects (there is an ActionItem.cfc component) Is there a way in ColdFusion to type-hint the array contents? What solution do you suggest in this case?