「Swift」Struct(構造体)の基本文法のサンプル

サンプルコード

struct rectangle {
    var length: Double
    var breadth: Double
    init() {
        length = 6
        breadth = 12
    }
}
var area = rectangle()
print("area:\(area.length*area.breadth)")

実行結果
area: 72.0

Swift

Posted by arkgame