Using “if let” with logical “or” operator

Try to use ?? operator:

if let amount = datasource?.incrementForCount?(count) ?? datasource?.fixedIncrement 
{
    count += amount
}

is it possible to combine the 2 if let statements into a single ORed one ?

It is possible to have several let statements like

if let a = optionalA, b = optionalB { ... }

And all of them should return non-nil value to pass.

But if you also want to use a logical condition it:

  1. Could be only the one
  2. Should be placed on the first place, before any let statements

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)