table.lookup_float

FLOATtable.lookup_floatIDidSTRINGkeyFLOATdefault

Available inall subroutines.

Looks up the key key in the table id. When the key is present, its associated value will be returned. When the key is absent, the default value is returned. The default value is required.

Example

# data from https://www.worldatlas.com/articles/continents-by-population-density.html
# as of sept. 2019
table population FLOAT {
"AF": 1.3, # Africa
"AN": 0.0, # Antarctica
"AS": 4.5, # Asia
"EU": 0.743, # Europe
"NA": 0.580, # North America
"OC": 0.0415, # Oceania
"SA": 0.429, # South America
}
declare local var.population FLOAT;
set var.population = table.lookup_float(population, client.geo.continent_code, 0.0);
if (var.population == 0.0) {
# unknown
} else if (var.population >= 1.0) {
# billions
} else {
# millions or below
}