-1

Currently I have a snippet of code that uses a bam operator but it needs to be unwrapped:

 if let tagIds = location.tagIds, !filterSet.matchesTags(tagIds as! [String]) {
            return false
        }

I tried using a guard:

  guard  let tagIds = location.tagIds, let tapgIdsString = tagIds as? [String] else {return}, !filterSet.matchesTags(tapgIdsString) {
            return false
        }

but it causes an error, "non-void function should return a value"

SwiftyJD
  • 5,257
  • 7
  • 41
  • 92

1 Answers1

0

Hard to answer without knowing how everything is declared, but it sounds like you could say

if let tagIds = location.tagIds as? [String], !filterSet.matchesTags(tagIds)
matt
  • 515,959
  • 87
  • 875
  • 1,141