From a7d55a9d338e15b817d841869a6edb42cb6c3899 Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Sat, 9 May 2026 21:08:53 +1000 Subject: [PATCH] Add highlighting to struct_definition.md --- src/struct_definition.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/struct_definition.md b/src/struct_definition.md index a23abb3..9a0aacc 100644 --- a/src/struct_definition.md +++ b/src/struct_definition.md @@ -4,7 +4,7 @@ Define a struct with the `struct` keyword. Syntax: -``` +```solstice struct StructName { ... } @@ -27,7 +27,7 @@ Inside the struct body, you can: A field in a struct is defined in the same way as a variable. -``` +```solstice struct MyStruct { x = 5 } @@ -39,7 +39,7 @@ This creates a field named `x` with a default value of `5`. A method in a struct is defined in the same way as a named function. -``` +```solstice struct MyStruct { def myMethod() int { return 0 @@ -50,7 +50,7 @@ struct MyStruct { Methods have access to the struct's members through the `self` object, which is implicitly passed. -``` +```solstice struct MyStruct { x = 10 @@ -71,7 +71,7 @@ All other fields are public, meaning anywhere in the program can read or write t Methods and special methods are by default protected, however can be made private. -``` +```solstice struct MyStruct { private x = 10 protected y = "Hi" @@ -92,7 +92,7 @@ A constructor is used to initialize an object with user-provided fields. Define a constructor like this: -``` +```solstice struct MyStruct { constructor(args) { ... @@ -110,7 +110,7 @@ where: Use a constructor like this: -``` +```solstice MyStruct(args) ``` @@ -123,7 +123,7 @@ A destructor is used to destroy an object once it goes out of scope. Define a destructor like this: -``` +```solstice struct MyStruct { destructor { ... @@ -144,7 +144,7 @@ A duplicator is used to copy an object when it is assigned to a new name, or pas Define a duplicator like this: -``` +```solstice struct MyStruct { duplicator { ... @@ -166,7 +166,7 @@ As methods allow easy conversion between different types. Define an as method like this: -``` +```solstice struct MyStruct { as type { ... @@ -182,7 +182,7 @@ where: Use an as method like this: -``` +```solstice myobj as type ```