I am taking the CS193 class. From this exact moment of the video.
Option 1:
class FaceView: UIView
{
var scale: CGFloat = 0.90
var mouthCurvature: Double = 1.0
private var skullRadius: CGFloat {
return min(bounds.size.width, bounds.size.height) / 2 * scale
}
}
Why can't I write
Option 2:
class FaceView: UIView
{
var scale: CGFloat = 0.90
var mouthCurvature: Double = 1.0
private var skullRadius = min(bounds.size.width, bounds.size.height) / 2 * scale
}
The professor goes and explains that you during initialization you can't access your own property and therefore if you do option 2, you will get an error saying: instance member 'bounds' cannot be used on type 'FaceView'
.
OK, but aren't we still accessing the instance member 'bounds` in Option 1 as well? What's the difference? Or is it that accessing is OK, but you can't make one property dependent on another during initialization?