src/melon/modules/object/object_module.c
static TByte hasKeyFunc(VM* vm)
{
    melM_arg(vm, obj, MELON_TYPE_OBJECT, 0);
    melM_arg(vm, key, MELON_TYPE_NONE, 1);

    Value* res = melGetValueObject(vm, obj->pack.obj, key);

    melM_stackEnsure(&vm->stack, vm->stack.top + 1);
    Value* result = melM_stackAllocRaw(&vm->stack);
    result->type = MELON_TYPE_BOOL;
    result->pack.value.boolean = res != NULL;

    return 1;
}
/***
 * Checks if the provided object has the requested key defined.
 * This can be used to be sure that an object has a key even if the associated value is `null`.
 * 
 * @arg obj The object holding the key
 * @arg key The key to check
 * 
 * @returns `true` if the key is present, `false` otherwise.
 */
Checks if the provided object has the requested key defined.
This can be used to be sure that an object has a key even if the associated value is `null`.

@arg obj The object holding the key
@arg key The key to check

@returns `true` if the key is present, `false` otherwise.
Checks if the provided object has the requested key defined . This can be used to be sure that an object has a key even if the associated value is ` null ` . @arg obj The object holding the key @arg key The key to check @returns ` true ` if the key is present ` false ` otherwise .
static TByte hasKeyFunc(VM* vm)
{
    melM_arg(vm, obj, MELON_TYPE_OBJECT, 0);
    melM_arg(vm, key, MELON_TYPE_NONE, 1);
    Value* res = melGetValueObject(vm, obj->pack.obj, key);
    melM_stackEnsure(&vm->stack, vm->stack.top + 1);
    Value* result = melM_stackAllocRaw(&vm->stack);
    result->type = MELON_TYPE_BOOL;
    result->pack.value.boolean = res != NULL;
    return 1;
}
static TByte hasKeyFunc ( VM * vm ) { melM_arg ( vm , obj , MELON_TYPE_OBJECT , 0 ) ; melM_arg ( vm , key , MELON_TYPE_NONE , 1 ) ; Value * res = melGetValueObject ( vm , obj -> pack . obj , key ) ; melM_stackEnsure ( & vm -> stack , vm -> stack . top + 1 ) ; Value * result = melM_stackAllocRaw ( & vm -> stack ) ; result -> type = MELON_TYPE_BOOL ; result -> pack . value . boolean = res != NULL ; return 1 ; }
Checks if the provided object has the requested key defined.
Checks if the provided object has the requested key defined .