I was wondering if I could have a case statement return a different value if a variable was true or false.
var variable = false
enum enumeraton {
case thing
var value: Int {
switch self {
case .thing:
if variable = true {
return 1
}else {
return 2
}
}
}
}
is there anyway to do this?
value. So maybe make a function (func value(withVariable: Bool) -> Int), or access it from the method (a singleton?)if-elsebeif variable == trueyou seem to be missing an equals sign in the condition