Hjertnes

Shortcuts & logic

2024-08-14 00:00

The thing I hate-enjoy the most about making Apple Shortcuts is how it encourages (because it lacks real complex logic or data structures) to write logic that takes shortcuts and kind of avoids checking all cases. Like with what I was doing when I got this post idea:

  • Two variables (a and b) that can have three states: Green, Yellow, Red.
  • Where the global state should be Red if either is Red, or Yellow if either is Yellow otherwise Green
  • Easy with a or something more fancy like a data structure that holds the results for each possible state
  • With Shortcuts I always find myself doing something like this
  1. Set Status to A
  2. Then a shit load of nested if
  3. If Status != Red
  4. If B != A
  5. If B != Green

In the same way you would in places where performance is very important and you only do what you have to do.

I could have re-written it to be numbers and found the largest ones, and then converted that to the statuses. But that isn’t really the point here: can we have some real if logic soon?!

Made with ❤️ in Bergen, Norway by Eivind Hjertnes