How to clear the variable after calling composer.setVariable()

I have something similar to the following:

composer.setVariable("id","12345") print(composer.getVariable("id")) -- outputs 12345

When I set nil to this variable like so:

composer.setVariable("id",nil) print(composer.getVariable("id")) -- outputs 12345

it still outputs 12345

I’d like to clear the variable.  How would I do that or is not possible using composer.setVariable?

Hi,

It seems not possible. Maybe use false to denote absence useful value. Then in code use

composer.setVariable( 'id', false ) --composer.setVariable( 'id', '12345' ) local id = composer.getVariable( 'id' ) if id then -- Use id else --No id end

Also -1 can be use but it need modification of if statement.

ldurniat 

composer.variables["id"] = nil

Hi,

It seems not possible. Maybe use false to denote absence useful value. Then in code use

composer.setVariable( 'id', false ) --composer.setVariable( 'id', '12345' ) local id = composer.getVariable( 'id' ) if id then -- Use id else --No id end

Also -1 can be use but it need modification of if statement.

ldurniat 

composer.variables["id"] = nil