aboutsummaryrefslogtreecommitdiff
path: root/examples/39-struct-methods/src/HelloWorld.shed
blob: cfba064d46953a551b3ec5c2646fea5bb29af283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub fun main() ! Io -> Unit {
    print!(Count(1).message());
    print!(Count(2).message());
    print!(Count(3).message());
}

struct Count(value: Int) {
    fun message(this) -> String {
        if (this.value == 1) {
            "one\n"
        } else if (this.value == 2) {
            "two\n"
        } else {
            "many\n"
        }
    }
}