module Tree

with method depth defined as before.

with method depth defined as before.

Now types `Tree(Empty | Leaf | Node)`, `Empty`, `Leaf(Integer)` and `Node(Tree, Tree)` are defined. Let's add a method, don't miss the **pattern matching** example.

Now types `Tree(Empty | Leaf | Node)`, `Empty`, `Leaf(Integer)` and `Node(Tree, Tree)` are defined. Let's add a method, don't miss the **pattern matching** example.

Public Instance Methods

depth() click to toggle source
# File doc/data.in.rb, line 10
def depth
  match self,
        Tip.to_m >> 0,
        Node.(any, ~any, ~any) >-> left, right do
          1 + [left.depth, right.depth].max
        end
end