RenaBeach wrote:e: except i saw that you were already reading it
You could set it up as a function that takes a list and returns a random value out of it, which you'd only need one of, and then you'd call it by passing in one of your three lists.
but type safetyyyyyyyy (but i guess they're already strings, lol)
Sure, it's predicated on the fact that you have repeated instances where you want to draw a random element out of a list of strings, specifically.
Otherwise there's always templates.
RenaBeach wrote:out of curiosity, what do you feel about C++ exceptions?
I'm wondering if I should start using them but I've never really been convinced with them
Personally, I feel like they get an unfairly bad rap. I can see no reason that
C++ exceptions are any worse than others (they work almost exactly the same way in other languages). People often bring up efficiency, but exceptions imo should not be used in instances where you care about efficiency.
I guess the issue is that they historically weren't adopted, which means it's hard to find engines that use them (unreal doesn't, for example), so the "word on the street" is that exceptions are just something you don't use.
So, that said, it's less about "C++" exceptions and more about exceptions in general. I think try-catch blocks are...arduous to write. In addition, it can be hard to decide whether an error is "worthy" of being an exception. Failing to find an element in a vector: probably not an exception. Failing to open a file for read: maybe an exception?
And because not everything is worthy of being an exception, now you've got two different error handling mechanisms floating around, which is confusing.
Honestly, in summary, I'm not super sure. I haven't yet worked on a project that heavily used exceptions, so I haven't been able to see what works and what doesn't.