0

I confuse with

static var str = "Hello1"

var str2: StaticString = "Hello2"

What is the best case to use StaticString?

How is static and StaticString allocate memory?

0

1 Answer 1

1

static string can be known at the compile time.

let str1: String = "str1" // ok
let str2: String = "\(str1) + 1" // ok
let str3: StaticString = "\(str1)" // illegal

StaticString has to be known.

let foo: StaticString = "foo" // ok

personally, i have only seen this used when creating some sort of a signpost functionality to test performance on the instruments

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.