var¶
classDiagram
EventHandling <|-- Var
Generic <|-- Var
Charmy vars.
These are used to implement thing like C(++) pointers. A var will be able to be referenced or modified from somewhere else, providing experience like C(++) pointers.
- class charmy.utils.var.Var(default_value: VarType | None = None)¶
基类:
EventHandling,Generic[VarType]Aimed to provide experience like C vars with pointers.
- Args:
default_value: The initial _value of the variable. value_type: The type of the variable.
- __init__(default_value: VarType | None = None)¶
- property value: VarType | None¶
The value stored in the var.
- charmy.utils.var.unpack_var(var_or_val: Var[VarType] | VarType, default: None = None) VarType | None¶
- charmy.utils.var.unpack_var(var_or_val: Var[VarType] | VarType, default: VarType) VarType
To convert a var to its value if param 1 is a var, otherwise return the param 1 as-is.
- 参数:
var_or_val -- The var to dispatch or the value to return as-is
default -- Value to return if the value of the var is False