0

Now, I've seen this swift error posted all over stackoverflow. However, the way they handle it won't seem to work in my situation.

if ( 
        fieldType == "checkbox" ||
        fieldType == "time" ||
        fieldType == "birthdate" ||
        fieldType == "datetime" ||
        fieldType == "phone" ||
        fieldType == "payment" ||
        fieldType == "stripe" ||
        fieldType == "paypal" ||
        fieldType == "paypalpro" ||
        fieldType == "address" ||
        fieldType == "2co")

{

Not sure how I can fix it. There must be some way to lower the complexity of it.

Ramsy Travis
  • 23
  • 1
  • 2

1 Answers1

0

What I would do is just start with an array of literals:

    let fieldType = "Howdy"
    let possibilities = ["checkbox","time"] // ... add the others too...
    if find(possibilities, fieldType) != nil { // or: if contains(possibilities,fieldType)
    }
matt
  • 515,959
  • 87
  • 875
  • 1,141