Cast (Expression) — ClassySK
Addon: ClassySK · Category: Expression · Since: 1.4.0
Syntax
%classinstances% as <[A-Z]\w*>Description
Cast instance(s) to a desired type. This may be useful in certain scenarios when working with super classes in methods/functions. Also useful for targeting specific overloads. When working with type hints, you'll need to do this to access certain methods if the variables type is implied as the super.
Examples
on load:
set {_y} to new Y
example({_y}) # Y is implicitly casted to X
class X
function example(x: X instance):
# do stuff with {_x}
if {_x} is an instance of Y: # good idea to check before casting so you dont pass an empty value
otherExample({_x} as Y)
class X extends Y
function otherExample(thing: Y instance):
# do stuff with {_y}