Typed/Untyped instance (Expression) — ClassySK
Addon: ClassySK · Category: Expression · Since: 1.1.0
Syntax
[un]typed %classinstance/typedinstance%Description
This expression can be used to wrap/unwrap an instance respective to it's given typed wrapper. This is useful is niche scenarios where the concrete type of the instance actually matters.
Examples
# if this were a generic instance the check would fail, so we make sure it's wrapped before doing a vanilla type check
# in this scenario it's recommended to use the dedicated 'is an instance of' condition though
if typed {_instance} is an Example instance
# with reflection we wanna make sure it's the correct type before calling methods on it
set {_value} to (untyped {_instance}).getFieldValue("myField")
# typed and untyped instances are also interfaced, so we could also just call unwrap() or wrap() respectively, which is what this expression does under the hood
set {_value} to {_instance}.unwrap().getFieldValue("myField")