If I have a function that should only accept odd integers, what’s the best way to implement this? Should I create a new OddInt type and only allow that, or just check whether the integer is odd inside the function and throw an error if it’s not? How would I even create an OddInt type in Julia?
function oddball(n::OddInt) println("I won't even bother if n isn't odd") end
function oddball(n::Int64) if isodd(n) println("good job") else throw("the int must be odd!") end end