I am currently coding my own app and I was looking at a coding video for help and the person in the video was using .text
and some other things that had dots in front of them like .color
and .shape
, which were variables declared and initialized already. I was wondering if anybody has a clear definition on what the .text
means or what it does and what the overall dot means whenever you use it.
This feature is called "Implicit Member Expression"
An implicit member expression is an abbreviated way to access a member of a type, such as an enumeration case or a class method, in a context where type inference can determine the implied type. It has the following form:
.member name
For example : if you want to pick a color, in Swift4 you can simply do so:
let color: UIColor = .green
instead of typing :
let color : UIColor = UIColor.green()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With