Defining a custom constructor for a type alias?

You can, they just need to be const, but then they can return anything, e.g. this works:

struct Stuff end
const boo = Array{Stuff,1}
boo(x,y,z) = "boo"
boo(1,2,3) # returns "boo" 

As long as you’re not commiting type piracy by say defining a new constructor for Array{Int,1}, I think this is reasonable to use.

2 Likes