Debian Codegraph @

examples/shred/parent.ck

raw
1 // return a shred's parent shred (i.e., the shred that sporked it)
2 // if the shred is a top-level shred, then me.parent() will return null
3 // related: ancestor.ck
4
5 <<< "the top-level shred's ID is:", me.id() >>>;
6 <<< "the top-level shred's parent is:", me.parent() >>>;
7
8 fun void findTheParent()
9 {
10 // this will be the same as the top-level shred id
11 <<< "the sporked shred's ID is:", me.id() >>>;
12 <<< "the sporked shred's parent ID is:", me.parent().id() >>>;
13 }
14
15 // spork a child shred
16 spork ~ findTheParent();
17
18 // yield to let validateParent(...) run
19 me.yield();