~mna/snow

snow/pkg/codegen/testdata/fn_nested_struct_method.snow -rw-r--r-- 367 bytes
424066c5Martin Angers doc: v0.0.5 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fn main() {
  struct S {
    var x: string

    struct T {
      var y: string

      ref fn append(s: string) {
        y = y + s
      }
    }

    ref fn init() {
      x = "hello"
    }
  }

  var s: S
  var t: S.T

  s.init()
  t.append(s.x)
  t.append(", world")
  println(t.y)
}

@extern(import: "fmt", symbol: "Println")
fn println(s: string)

#=hello, world