Taking on new clients for Elixir and web development.
Mike Zornek

Swift UInt vs Int

Posted on

I’m giving major consideration to utilizing Swift’s UInt type for function returns and calculated properties in the future.

Yes this does burden the user of my code or SDK to do the occasional type conversion, which is the only reason I’ve ever heard why the community uses Int even for variables that should not be negative, but I think the expressiveness outweighs the negative of more code.

I generally like to fall in line with the community when it comes to coding standards to help my code “fit in” but this issue has bothered me since day one of learning Swift. Would love to hear some feedback on this from experienced Swift developers.


About the Author. Mike Zornek is a developer and teacher focusing on product design and development with a heavy focus on Elixir and LiveView. In between his projects, Mike helps other teams through consulting. During off hours, he enjoyed watching Phillies baseball and playing relaxing video games.