marqdo

09-inheritok

structure/09-inherit.mq.md

Structure

fn · h1Greeter
fn · h2hello
who
bind `msg` = Hello, `who`!
return`msg`
fn · h1Loud
fn · h2hello
who
bind `msg` = HELLO, `who`!
return`msg`
fn · h1main
bind `g` = > Greeter
bind `m` = > `g`.hello who=world
call> print text=`m`
bind `l` = > Loud
bind `m2` = > `l`.hello who=world
call> print text=`m2`
Functions
Variables
  • g Greeter
    _typeGreeter
  • l Loud
    _typeLoud
  • m text
    Hello, world!
  • m2 text
    HELLO, world!

Execution

Hello, world! HELLO, world!

Source

---
title: Object inheritance
description: "# Child = > Parent; methods walk the base chain"
---

# Greeter

## hello
    + `who`

**`msg` = "Hello, `who`!"**
*`msg`*

# Loud = > Greeter

## hello
    + `who`

**`msg` = "HELLO, `who`!"**
*`msg`*

# main

**`g` = > Greeter**
**`m` = > `g`.hello who="world"**
> print text=`m`
**`l` = > Loud**
**`m2` = > `l`.hello who="world"**
> print text=`m2`

Variable