You can always use map
with a do
block:
results = map(1:10) do i
....
end
The map
function already implements the type-narrowing deduction you want. It uses Julia’s type inference as an optimization, but works even when type-inference fails.