#Is `anytype` the only way to make generic function parameters?

1 messages · Page 1 of 1 (latest)

drifting warren
#

I have a function that takes a slice as one of it's parameters. However, there are increasingly times where I want to pass in a single pointer, rather than wrapping it in a new slice.

I know I could change the parameter type to anytype and have the function check whether it is a slice, but I lose compiler visibility on valid types. Is there any other way to implement this?

undone dirge
#

if you need to support multiple types then anytype is the way to go, yes
there's no signature overloading in zig

drifting warren
#

That's what I figured. Thanks!

grim relic