Suppose I have a record named #parameters, and I am accessing it from outside and I do not know if all the keys inside it have a value stored with it.
Suppose there is a key in my record named Index. How can I check if the value for Index is present in my record or not? And how do I put it in a case statement like:
Index = find from the record
or else put it as 100.
All fields in a record have a value. If a default value for a field is not specified in the record definition, then erlang uses the atom
undefinedfor the default value. For instance:In the shell,
Once again, there will always be a value for the
indexkey. Here's an example that demonstrates how to do one thing ifindexhas the valueundefinedand do something else ifindexhas some other value.In the shell:
You could also turn the
check_index()function into a boolean function that returns true or false.