Swift: how to pass global variables through switch/case : I realise this has been asked before, but the answer here (to declare the variable outside the block) doesn't seem to work.
[link description][1]

    var filter: String
    
    switch arguments {
    ....
    default:
    filter = "value"
    print(filter)
    }
    print(filter)

I get "value" in Xcode's playground for the first print, but the second gives "\n"
What am I doing wrong?


  [1]: https://stackoverflow.com/questions/25959680/how-do-i-increase-the-scope-of-variables-in-switch-case-loops-in-swift