All *Value objects follow the same template so it makes sense that people will write code that can operate on all of them. But when I want to make sure I’m working with one of them and not something else I need to do like 10 IsA calls to check every class name (IsA(“BoolValue”) or IsA(“CFrameValue”) or IsA(“StringValue”) …). I should be able to just do IsA(“ValueContainer”).
I like the idea. They wouldn’t inherit anything specific to from the ValueContainer though. The existence of ValueContainer would be solely for organization.
An alternative to checking all 10 object types, you could use string.find(object.className,‘Value’)
If you’re worried about solely line count…
if string.find(v.ClassName, "Value") then
Edit: Completely missed Lukes post. College sleep hours are getting to me…
Pretty sure it’s better to do
if string.sub(object.ClassName, -5) == "Value" then
Or better yet:
if obj.Classname:match("Value$") then
On-topic: Yes, this would be great!
Off-topic:
Performance of previous three posts (corrected for empty loop time and indexing objects)
Time passed: 0.3610372543335 -- find
Time passed: 0.35981893539429 -- sub
Time passed: 0.38161563873291 -- match
Doesn’t really matter, sub is a bit faster because it just takes part of the data and checks it with one string, it doesn’t perform any pattern matching or having to find “Value” across the entire string.
Use sub because it’s the simplest, not because it’s the fastest.