Type Safely

Share this post
Use The 'some' Keyword For Any Function Parameter That Conforms To a Protocol
typesafely.substack.com

Use The 'some' Keyword For Any Function Parameter That Conforms To a Protocol

Daily Coding Tip 119

Rob Sturgeon
Jun 29
Share this post
Use The 'some' Keyword For Any Function Parameter That Conforms To a Protocol
typesafely.substack.com
Image by Kevin Schwarz from Pixabay

Here’s a simple protocol that requires a type to have a string property called spelled. This means I want a numeric type that conforms to this to be able to spell out the word name for that number, for instance ‘one’ or ‘two’. Luckily there’s a fairly easy way to conform to this protocol by using a NumberFormatter, whi…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2022 Type Safely
Privacy ∙ Terms ∙ Collection notice
Publish on Substack Get the app
Substack is the home for great writing