Expected an expression that can fail in the 'if' condition clause

I am trying to access the ScoreManager device from a VoteDevice (a class I made). Doing this using VoteDevices[ButtonIndex].ScoreManager works, but why does the statement at the bottom fail?

I already know VoteDevice exists because of the line: if (VoteDevice := VoteDevices[ButtonIndex]. Then why does it make a difference whether I use VoteDevices[ButtonIndex].ScoreManager or simply VoteDevice.ScoreManager

Hi @JoeriDukker :

Indexing (i.e. the [] operator and thus the expression VoteDevices[ButtonIndex]) is considered a failable operation, since you could go out-of-bounds when accessing an element in an array. The expression ScoreManagerTest := VoteDevice.ScoreManager is just an assignment, which in of itself is not failable.

Hopefully that answers the question.

2 Likes