Thanks to SE-0228, you can control exactly how you want string interpolations to print. Thank you Brent for giving this to us. It’s a doozy! Let me share some examples…
Consider printing optionals. You use:
And get an instant warning:
You can click the fixes to suppress the warning but you’ll still get an output that looks like this: “There’s Optional(23) and nil”.
Now you can strip the “Optional” and produce “There’s 23 and nil”, allowing you to print values directly:
You might create a set of styles and custom interpolation to support consistent presentation for optional output:
Interpolation isn’t limited to tweaking optionals. Say you want to control whether a string is added without having to use a ternary expression with an empty string:
There’s lots more you can do and it’s all exciting and fun.