Is there better way to create a `AttributedString` for a let property?

struct AttributedStringMarkdownList: View {
    let s: AttributedString = {
        do {
            return try AttributedString(
                markdown: """
                    - Lorem ipsum dolor sit amet.
                    - Ut dolores quaerat non nesciunt nobis ut ullam galisum ea dolorum sint sit repudiandae placeat ut ipsa quia.
                    - At internos voluptatibus ea repellat assumenda et fuga dicta ea voluptatum repellendus aut libero reiciendis.
        } catch {

    var body: some View {

(BTW, markdown list doesn't seem to work, maybe it's not implemented?)

Any reason you can't simply do let s = try! AttributedString(markdown: "...") if you are just going to fatalError?


No reason. Just didn't think of it.


1 Like