mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler/lang: add variadic function args support
This commit is contained in:

committed by
Alexander Medvednikov

parent
5fb3c0e3a8
commit
f7c8e923c0
@ -56,13 +56,6 @@ type actionf_p1 fn (voidptr)
|
||||
|
||||
type actionf_p2 fn (voidptr, voidptr)
|
||||
|
||||
fn myprint(s string, ..) {
|
||||
println('my print')
|
||||
println('// comment')
|
||||
println('/* comment */')
|
||||
println('/* /* comment */ */')
|
||||
}
|
||||
|
||||
// TODO
|
||||
fn modify_array(a mut []int) {
|
||||
a[0] = 10
|
||||
|
15
compiler/tests/fn_variadic_test.v
Normal file
15
compiler/tests/fn_variadic_test.v
Normal file
@ -0,0 +1,15 @@
|
||||
struct VaTestGroup {
|
||||
name string
|
||||
}
|
||||
|
||||
fn variadic_test_a(name string, groups ...VaTestGroup) {
|
||||
assert groups.len == 2
|
||||
assert groups[0].name == 'users'
|
||||
assert groups[1].name == 'admins'
|
||||
}
|
||||
|
||||
fn test_fn_variadic() {
|
||||
group1 := VaTestGroup{name: 'users'}
|
||||
group2 := VaTestGroup{name: 'admins'}
|
||||
variadic_test_a('joe', group1, group2)
|
||||
}
|
Reference in New Issue
Block a user