Forum Discussion
EnTerr
11 years agoRoku Guru
"RokuKC" wrote:
Note that there are components other than String / roString that implement the ifString interface.
This may be academic in your case, but if your intent is to truly identify string objects that have regular string object behavior I would advise doing the lcase(type(x)) = "string" etc. comparison as TheEndless demonstrated.
Similarly for ifInt et al.
Mmmm, good point.
I see roPath does ifString but who does ifInt (but roInt)?
Personally per my Python exposure i am fan of "duck typing" ("if it walks like a duck and swims like a duck and quacks like a duck, i call that [type] a duck"). In other words if the type can perform the duties of a String, for all practical purposes it is a string. Which i can probably check if the value can/has ifStringOps, to be more precise.
It would be very, very rare (methinks) that someone will ever need the real type(val) - and then they'd probably want to check type(val, 3) too.
PS. ultimateley, the advantage of DIY "isString()" is it can be fine tuned to one's needs