Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 22454

How do I subclass a struct in Swift?

$
0
0
struct MyRect : CGRect {...}

Is it possible at all in swift to subclass a Structure?

I have already found out on Apple official website an example:This example extends the CGRect structure to contain a computed area property:

extension CGRect {    var area: CGFloat {        return width * height    }}let rect = CGRect(x: 0.0, y: 0.0, width: 10.0, height: 50.0)let area = rect.area

How can i define a subclass of a structure ?


Viewing all articles
Browse latest Browse all 22454

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>