相同点react
不一样点swift
简单使用数组
struct Size {
var width: Double = 0
var heigtht: Double = 0
func description() {
print("width:\(width) height:\(heigtht)")
}
}
class React {
var size = Size()
var area: Double {
get {
return size.width * size.heigtht
}
}
func description() {
print("size:\(size) area:\(area)")
}
}
var size = Size()
var react = React()
size.description()
react.description()
react.size.width = 10
react.size.heigtht = 15
react.description()
复制代码
struct Size {
var width: Double = 0
var heigtht: Double = 0
func description() {
print("width:\(width) height:\(heigtht)")
}
}
class React {
var size = Size()
var area: Double {
get {
return size.width * size.heigtht
}
}
func description() {
print("size:\(size) area:\(area)")
}
}
var size = Size(width: 13, heigtht: 15)
size.description()
复制代码
enum Num {
case one, two, three, four
}
var a = Num.one
var b = a
a = .three
if b == .one {
print("内存独立")
}
复制代码
struct Size {
var width: Double = 0
var heigtht: Double = 0
func description() {
print("width:\(width) height:\(heigtht)")
}
}
class React {
var size = Size()
var area: Double {
get {
return size.width * size.heigtht
}
}
func description() {
print("size:\(size) area:\(area)")
}
}
var size = Size(width: 13, heigtht: 15)
let size1 = size
size.width = 100
size1.description()
var react = React()
var react1 = react
react.size.width = 10
react.size.heigtht = 20
react1.description()
复制代码
struct Size {
var width: Double = 0
var heigtht: Double = 0
func description() {
print("width:\(width) height:\(heigtht)")
}
}
class React {
var size = Size()
var area: Double {
get {
return size.width * size.heigtht
}
}
func description() {
print("size:\(size) area:\(area)")
}
}
var size = Size(width: 13, heigtht: 15)
let size1 = size
size.width = 100
size1.description()
var react = React()
var react1 = react
var react2 = React()
react.size.width = 10
react.size.heigtht = 20
react1.description()
if react1 === react {
print("react1 === react")
}else{
print("react1 !== react")
}
if react2 === react {
print("react2 === react")
}else{
print("react2 !== react")
}
复制代码
类与结构体的选择bash
swift中的值传递数据结构