I don't know the format name of variable name + block.

Asked 2 years ago, Updated 2 years ago, 55 views

Thank you for your continuous support.

Do you know the format name of the code below?
It doesn't seem to initialize the closure (because there is no =).
I asked you a question because I didn't understand when I looked it up.

var value: String?{return"abc"}
print(value!)//abc

Thank you for your cooperation.

swift3

2022-09-30 16:36

1 Answers

I'm sorry.
Self-resolved.

The way the get, set of properties is described is to omit get.
In this case, it is read-only.

https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html

var value: String?{return"abc"}
print(value!)
// value = "ABC" ... Error because it is read-only

Thank you.


2022-09-30 16:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.