~mna/snow

snow/pkg/codegen/testdata/fn_struct_init_fields.snow.want -rw-r--r-- 465 bytes
424066c5Martin Angers doc: v0.0.5 1 year, 8 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
31
32
33
34
35
36
37
38
39
package main

import "fmt"

type _اS struct {
	_اx int
	_اy string
	_اz bool
}

func _اSاnew(
	s _اS,
	m map[string]bool,
) _اS {
	var r _اS
	r._اx = 1
	if m["x"] {
		r._اx = s._اx
	}
	if m["y"] {
		r._اy = s._اy
	}
	r._اz = true
	if m["z"] {
		r._اz = s._اz
	}
	return r
}

func main() {
	var s _اS = _اSاnew(_اS{_اy: "a", _اz: false}, map[string]bool{"y": true, "z": true})
	_اprintln(s)
}

func _اprintln(
	s _اS,
) {
	fmt.Println(s)
}