Skip to content

Commit

Permalink
🧠 added examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aym-n committed Jan 11, 2024
1 parent 40b2364 commit 21163fc
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/classes.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Breakfast {
cook() {
print "Eggs a-fryin'!";
}

serve(who) {
print "Enjoy your breakfast, " + who + ".";
}
}

var someVariable = Breakfast();
someVariable.serve("arc");
11 changes: 11 additions & 0 deletions examples/doughnut.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Doughnut {
cook() {
print "Fry until golden brown.";
}
}

class BostonCream < Doughnut {}

~ cook() method is inherited from `Doughnut` to 'BostonCream'

BostonCream().cook();
2 changes: 2 additions & 0 deletions examples/hello-world.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
~ First arc program
print "Hello, world!";
12 changes: 12 additions & 0 deletions examples/local-functions.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn returnFunction() {
var outside = "outside";

fn inner() {
print outside;
}

return inner;
}

var fun = returnFunction();
fun();
16 changes: 16 additions & 0 deletions examples/super-doughnut.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Doughnut {
cook() {
print "Fry until golden brown.";
}
}

class BostonCream < Doughnut {
cook() {
super.cook();
print "Pipe full of custard and coat with chocolate.";
}
}

~ super.cook() calls cook() method in superclass 'Doughnut'

BostonCream().cook();

0 comments on commit 21163fc

Please sign in to comment.