2

Disclaimer: Although I mention my use in matlab I think this is is more of a programming pattern question so I put it here. If I am incorrect I will be happy to go over to stackoverflow.

I have a variable comprising of strings array which acts like a database I need to refer to in several functions in my program. It gets initialized at the start of the program and then remains static. I need to search particular string in the variable an return the index. I don't want to use global variables because they are bad patterns usually. But in this case the next best thing I can come up with is to make a searchDB(string1) function which has a persistent variable to hold the string array. But this does not sound like a very good solution. What are some other ways to implement it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.