Open jdehaan2014 opened 2 years ago
In the answers to the challenge to make the hash table accept Value as a Key, I have a question on TableGet. The diff states:
-bool tableGet(Table table, ObjString key, Value value) { +bool tableGet(Table table, Value key, Value* value) { if (table->entries == NULL) return false;
Entry* entry = findEntry(table->entries, table->capacity, key); -if (entry->key == NULL) return false; +if (IS_NIL(entry->key)) return false;
Should that last line not read:
+if (IS_EMPTY(entry->key)) return false;
This because we prefill the table with keys as Empty, and also in the TableDelete, we fill the key as Empty. This means a Key will never be Nil. Or do I make a thinking mistake here?
In the answers to the challenge to make the hash table accept Value as a Key, I have a question on TableGet. The diff states:
-bool tableGet(Table table, ObjString key, Value value) { +bool tableGet(Table table, Value key, Value* value) { if (table->entries == NULL) return false;
Entry* entry = findEntry(table->entries, table->capacity, key); -if (entry->key == NULL) return false; +if (IS_NIL(entry->key)) return false;
Should that last line not read:
+if (IS_EMPTY(entry->key)) return false;
This because we prefill the table with keys as Empty, and also in the TableDelete, we fill the key as Empty. This means a Key will never be Nil. Or do I make a thinking mistake here?