current position:Home>Swiftui advanced skills: what is the use of the technology of swift phantom type phantom

Swiftui advanced skills: what is the use of the technology of swift phantom type phantom

2022-05-15 07:37:38Fat knowledge

What is the phantom type ?

A phantom type is a piece of type information that has no runtime meaning . We use phantom types to add type information where we don't need runtime representation . Phantom types allow us to improve type security , Even better organize your code !

Why care about type safety ?

There are two main reasons for thinking :

  • Make the source code more expressive , Easier to understand 、 Reasoning and maintenance .
  • Prevent runtime errors .

copyright notice
author[Fat knowledge],Please bring the original link to reprint, thank you.
https://en.chowdera.com/2022/131/202205102133042705.html

Random recommended