Cookbook: Difference between revisions

No change in size ,  21 August 2012
m
(→‎Structures: use a less morbid example)
m (→‎Problem: typo)
Line 4: Line 4:
=== Retrieve a field value from all entries in a struct array ===
=== Retrieve a field value from all entries in a struct array ===
==== Problem ====
==== Problem ====
You have a struct array with multiple fields, and you want to acess the value from a specific field from all elements. For example, you want to return the age from all pacients in the following case:
You have a struct array with multiple fields, and you want to acess the value from a specific field from all elements. For example, you want to return the age from all patients in the following case:


   samples = struct ("patient", {"Bob", "Kevin", "Bob" , "Andrew"},
   samples = struct ("patient", {"Bob", "Kevin", "Bob" , "Andrew"},