sonolus.script.record¶
For usage details, see the corresponding concepts page.
Record
¶
Bases: GenericValue
Base class for user-defined data structures.
Usage
A regular record:
class MyRecord(Record):
field1: int
field2: bool
A generic record:
class MyGenericRecord[T, U](Record):
field1: T
field2: U
Creating an instance:
record = MyRecord(field1=42, field2=True)
record_2 = MyGenericRecord[int, int](field1=42, field2=100)
record_3 = MyGenericRecord(field1=42, field2=100) # Type arguments can be inferred
record_4 = +MyRecord # Create a zero-initialized record
record_5 = +MyGenericRecord[int, int]
type_var_value(var)
classmethod
¶
Return the value of a type variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var
|
TypeVar
|
The type variable to get the value of. |
required |
Returns:
Type | Description |
---|---|
Any
|
The value of the type variable. |