if文の簡単なリファクタの話
変更前
///ここのboolに通信とかで何かしらの真偽値が入る前提
let bool: Bool = .init()
var str: String = ""
if bool == true {
str = "hoge"
} else {
str = "hogehoge"
}
変更後
let bool: Bool = .init()
var str: String = bool ? "hoge" : "hogehoge"
Go to list of users who liked
More than 3 years have passed since last update.
if文の簡単なリファクタの話
変更前
///ここのboolに通信とかで何かしらの真偽値が入る前提
let bool: Bool = .init()
var str: String = ""
if bool == true {
str = "hoge"
} else {
str = "hogehoge"
}
変更後
let bool: Bool = .init()
var str: String = bool ? "hoge" : "hogehoge"
Register as a new user and use Qiita more conveniently
Go to list of users who liked