Help pls. How do you remove a variable item from a list?


I have a list of objects (called l) and I want to remove one from the list. However the one I want to remove is stored in a variable (called ob) and for some reason Inform does not like:

remove ob from l if present;


Problem. You wrote ‘remove ob from l if present’ , but ‘ob’ is a temporary name for a thing (created by ‘let’ or ‘repeat’), whereas I was expecting to find a list of values there.

Which suggests you can only remove set things from lists rather than calculated values.

I cannot find any example which does this and the manual only shows you removing constants (like remove cap from l if present or remove 7 from l if present.

Short of having a loop and copying everything from one list to another minus whatever is in ob I’m stumped.

Is there any way of removing something in a variable from a list?

It shouldn’t be a problem; not quite sure what’s going on here.

The issue seems to be that ‘remove X from Y’ can take two forms: one where X is some kind of value, and one where it’s a list; and for some reason it’s expecting a list here, but finding a temporary variable for a thing. No idea why. Can you post the whole code block?

I think you want “remove ob from l, if present” – with the comma.