DEV Community

Discussion on: I'm a senior developer and I regularly google "html image tag"

justinledwards profile image
Justin Edwards

I prefer string interpolation on languages that support it.

let multiplier = 3
let message = "\(multiplier) times 2.5 is \(Double(multiplier) * 2.5)"
// message is "3 times 2.5 is 7.5

tailcall profile image
Anton Istomin • Edited on

I agree, string interpolation is cool, but sometimes I feel that some simple operations are more readable if you just use concatenation, like when adding a prefix to a string.

let prefixedString = prefix + string
// versus
let prefixedString = "\(prefix)\(string)"

When my brain sees latter, it thinks "oh, some serious formatting is probably going on here, I should totally spend time and energy to carefully investigate it".