diff --git a/doc/docs.md b/doc/docs.md index 40cbf2fb2a..4e6a713344 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -6065,6 +6065,30 @@ fn main() { // test2 returns string: foo ``` +####

.params

+ +You can retrieve information about struct method params. + +```v +struct Test { +} + +fn (t Test) foo(arg1 int, arg2 string) { +} + +fn main() { + $for m in Test.methods { + $for param in m.params { + println('${typeof(param.typ).name}: ${param.name}') + } + } +} + +// Output: +// int: arg1 +// string: arg2 +``` + See [`examples/compiletime/reflection.v`](/examples/compiletime/reflection.v) for a more complete example. @@ -8040,4 +8064,4 @@ Assignment Operators &= |= ^= >>= <<= >>>= &&= ||= -``` +``` \ No newline at end of file