is it evil to use eval to convert a string to a function? [closed]

i have heard lot’s of different opinions on eval()

eval is not evil in general, there are applications for it.

unsure if it’s ok to use eval() in this context

No, it is not OK for this. There is a much better solution using the simple bracket notation member operator. Since this is asked every day on SO, I can list hundreds of dupes here (just the first few Google results):

Leave a Comment