Is it possible to use a String/Character literal within string interpolation in Swift?
The language reference says:
The expression you write inside parentheses within an interpolated string cannot contain an unescaped double quote (") ...
That's a little fuzzy to me, since it seems to deliberately leave the loophole of escaped double quotes.
If I try:
println( "Output: \(repeat("H",20))" );
func repeat( char:Character, times:Int ) -> String {
var output:String = "";
for index in 1...times {
output += char;
}
return output;
}
I get "Expected ',' separator".
Similarly, if I do the same thing, but escape the quotes, still no dice:
println( "Output: \(repeat(\"H\",20))" );
I suspect it's just not possible, and to be honest, no big deal -- I haven't found any example that I can't easily solve by doing a little work before the string interpolation, I guess I'm just looking for confirmation that it's just not possible.