When running this code from command line it works fine.
System Version: macOS 12.0 (21A5294g)
Tested Playgrounds both iOS and Mac platform. Both failed but the code is fine.
It is just a Playground issue.
Could someone make sure this bug was filed with the XCode Playgrounds team.
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
Tags: