Skip to content

Commit

Permalink
added more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmasoldi3r committed Nov 2, 2023
1 parent e5c00f9 commit 034400e
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions examples/oop.saturn
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
// Example of OOP possible uses with std
let { abstract, entries, mixin, trait, impl } = require("../src/assets/std");

class Simple {}
// Simple abstract class example.
class SimpleAbstract {
@abstract() fn example(self) {}
fn inherited(self) {
print("This was inherited " ++ self.name);
}
}

@mixin(SimpleAbstract)
class Simple {
fn example(self) {
print("Won't blow.");
}
fn run() {
let example = Simple { name: "Simple example" };
example.example();
example.inherited();
}
}
Simple::run();

// Trait example
@trait()
class TraitLike {
@abstract() fn foo(self) {}
fn foo(self) {}
}

@impl(TraitLike)
Expand All @@ -18,6 +38,7 @@ class Implementor {
}
}

// Mixin examples
@mixin(Implementor)
class Child {
fn me(self) {
Expand Down

0 comments on commit 034400e

Please sign in to comment.