What silly thing am i doing here

screenshot

unlockContent and authoriseSale only exist within the scope of the if { } statements. If you want to use them outside the if { } statements you'll need to define them at a higher scope. For example:

let unlockContent = loggedIn && proUser
1 Like

The first silly thing you are doing, is creating a local variable inside the if block, when you presumably want it to be available outside that block. Try this instead:

let foo: Bool
if condition {
  foo = true
}

Or, better still, this:

let foo = condition
if foo {
  // do other stuff
}

The second silly thing you are doing, is posting a screenshot to the forums instead of copying and pasting code. To use code formatting on the forums, place the code between triple backticks (```) on lines above and below.

Terms of Service

Privacy Policy

Cookie Policy