You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.2 KiB

name: duk_next
proto: |
duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value);
stack: |
[ ... enum! ... ] -> [ ... enum! ... ] (if enum empty; function returns zero)
[ ... enum! ... ] -> [ ... enum! ... key! ] (if enum not empty and get_value == 0; function returns non-zero)
[ ... enum! ... ] -> [ ... enum! ... key! value! ] (if enum not empty and get_value != 0; function returns non-zero)
summary: |
<p>Get the next key (and optionally value) from an enumerator created with
<code><a href="#duk_enum">duk_enum()</a></code>. If the enumeration has been
exhausted, nothing is pushed to the stack and the function returns zero.
Otherwise the key is pushed to the stack, followed by the value if
<code>get_value</code> is non-zero, and the function returns non-zero.
</p>
<p>Note that getting the value may invoke a getter which may have arbitrary
side effects (and may throw an error).</p>
example: |
while (duk_next(ctx, enum_idx, 1)) {
printf("key=%s, value=%s\n", duk_to_string(ctx, -2), duk_to_string(ctx, -1));
duk_pop_2(ctx);
}
tags:
- object
- property
seealso:
- duk_enum
introduced: 1.0.0