Accessing a changing field within a java object

2 vues (au cours des 30 derniers jours)
Wade
Wade le 21 Août 2012
I have a function that is looking up an identification tag in an object based on a string. The string can be either in the name field or the comment field if the name field doesn't exist.
Example: name field
obj.name
Example: comment field
obj.comment
I have a function that allows the user to specify the object and which field they want
function(obj,field)
How do I construct a call to the object field from this?
If I simply put something like
obj.field
I get an error because field is not a valid field in the object.
Thanks!

Réponses (1)

Oleg Komarov
Oleg Komarov le 21 Août 2012

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by