xHarbour Reference Documentation > Function Reference |
Removes a key/value pair from the hash by its key.
HDel( <hHash>, <xKey> ) --> NIL
The function returns always NIL.
The function removes a key/value pair from the hash <hHash>. If the key <xKey> is not found in the hash, a runtime error is raised. Use function HHasKey() to determine the existence of a key.
Note: deleting a key is the only way to change a key in a hash. If the value must be preserved, use function HGet() to retrieve the value, then remove the key, and finally add the new key with the preserved value.
See also: | Hash(), HDelAt(), HGet(), HHasKey(), HSet() |
Category: | Hash functions , xHarbour extensions |
Source: | vm\hash.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The function deletes a key/value pair from a hash by key. PROCEDURE Main LOCAL hHash := Hash( "A",10, "B",20 , "C",30 , "D",40 ) HDel( hHash, "C" ) ? ValToPrg( hHash ) // result: { "A" => 10, "B" => 20, "D" => 40 } RETURN
http://www.xHarbour.com