Community discussions

MikroTik App
 
jeroenp
Member Candidate
Member Candidate
Topic Author
Posts: 159
Joined: Mon Mar 17, 2014 11:30 am
Location: Amsterdam
Contact:

How to remove entry in associative array?

Thu May 12, 2016 12:53 am

Now that I know how to start with an empty associative array and fill it: what about the other way around and remove an entry form an associative array?

i.e. how to remove the element with key `b` in the code below:
:global rot13 ({});
:set ($rot13->"a") "n"
:set ($rot13->"b") "o"
:set ($rot13->"c") "p"
--jeroen
 
alli
newbie
Posts: 35
Joined: Tue Jan 24, 2017 5:43 pm

Re: How to remove entry in associative array?

Wed Jun 13, 2018 4:16 am

Calling :set on variable or array elements without any value seems to work like unset (v6.42.3), check this:
:global a {b=1}
/environment print
:set ($a->"b")
/environment print
:set $a
/environment print

Who is online

Users browsing this forum: No registered users and 16 guests